Skip to content

Commit

Permalink
Merge pull request #14 from wombelix/feat_pdf_mtime_equal_article
Browse files Browse the repository at this point in the history
  • Loading branch information
justinmayer committed Jul 3, 2023
2 parents 421056b + d55c464 commit fb6a2de
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions pelican/plugins/pdf/pdf.py
Expand Up @@ -9,6 +9,7 @@
import logging
import os
import re
import time

from rst2pdf.createpdf import RstToPdf

Expand Down Expand Up @@ -98,6 +99,9 @@ def _create_pdf(self, obj, output_path):

self.pdfcreator.createPdf(text=(header + text), output=output_pdf)

if obj.date is not None:
self._set_file_utime(output_pdf, obj.date)

def _get_intrasite_link_regex(self):
intrasite_link_regex = self.settings["INTRASITE_LINK_REGEX"]
regex = r"""
Expand All @@ -107,6 +111,11 @@ def _get_intrasite_link_regex(self):
)
return re.compile(regex, re.X)

def _set_file_utime(self, path, datetime):
"""Set modified time (mtime) of specified file."""
mtime = time.mktime(datetime.timetuple())
os.utime(path, (mtime, mtime))

def generate_context(self):
pass

Expand Down

0 comments on commit fb6a2de

Please sign in to comment.