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.
This commit is contained in:
parent
9c3753ed2b
commit
85efd9a80a
1 changed files with 2 additions and 2 deletions
|
@ -723,7 +723,7 @@ class pdfdoc(object):
|
||||||
|
|
||||||
def datetime_to_pdfdate(dt):
|
def datetime_to_pdfdate(dt):
|
||||||
dt_utc = dt.astimezone(tz=timezone.utc)
|
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"]:
|
for k in ["Title", "Author", "Creator", "Producer", "Subject"]:
|
||||||
v = locals()[k.lower()]
|
v = locals()[k.lower()]
|
||||||
|
@ -754,7 +754,7 @@ class pdfdoc(object):
|
||||||
|
|
||||||
def datetime_to_xmpdate(dt):
|
def datetime_to_xmpdate(dt):
|
||||||
dt_utc = dt.astimezone(tz=timezone.utc)
|
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"""<?xpacket begin='\xef\xbb\xbf' id='W5M0MpCehiHzreSzNTczkc9d'?>
|
self.xmp = b"""<?xpacket begin='\xef\xbb\xbf' id='W5M0MpCehiHzreSzNTczkc9d'?>
|
||||||
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='XMP toolkit 2.9.1-13, framework 1.6'>
|
<x:xmpmeta xmlns:x='adobe:ns:meta/' x:xmptk='XMP toolkit 2.9.1-13, framework 1.6'>
|
||||||
|
|
Loading…
Reference in a new issue