From 85efd9a80a1eb6043a9bfa1a6398072a51a0785a Mon Sep 17 00:00:00 2001 From: Patrick McCarty Date: Sat, 10 Jun 2023 17:28:02 -0700 Subject: [PATCH] Fix format of PDF and XMP timezone offsets The way to specify timezone offsets differs between the PDF and XMP specs, so hardcode the UTC offset instead of using `%z`. This also avoids the possibility of embedding the more more granular timezones supported by the datetime module but that are unsupported by either PDF or XMP formats. --- src/img2pdf.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/img2pdf.py b/src/img2pdf.py index 0e5fbda..80158e1 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -723,7 +723,7 @@ class pdfdoc(object): def datetime_to_pdfdate(dt): dt_utc = dt.astimezone(tz=timezone.utc) - return dt_utc.strftime("%Y%m%d%H%M%S%z") + return dt_utc.strftime("%Y%m%d%H%M%S+00'00'") for k in ["Title", "Author", "Creator", "Producer", "Subject"]: v = locals()[k.lower()] @@ -754,7 +754,7 @@ class pdfdoc(object): def datetime_to_xmpdate(dt): dt_utc = dt.astimezone(tz=timezone.utc) - return dt_utc.strftime("%Y-%m-%dT%H:%M:%S%z") + return dt_utc.strftime("%Y-%m-%dT%H:%M:%S+00:00") self.xmp = b"""