Skip to content

Commit

Permalink
Don't crash when using UTC timezones
Browse files Browse the repository at this point in the history
Fix #862.
  • Loading branch information
liZe committed May 14, 2019
1 parent 2fa7c2f commit 840c4a6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
11 changes: 7 additions & 4 deletions weasyprint/document.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,13 @@ def _w3c_date_to_iso(string, attr_name):
int(groups['second'] or 0))
if groups['hour']:
assert groups['minute']
assert groups['tz_hour'].startswith(('+', '-'))
assert groups['tz_minute']
iso_date += '%+03i:%02i' % (
int(groups['tz_hour']), int(groups['tz_minute']))
if groups['tz_hour']:
assert groups['tz_hour'].startswith(('+', '-'))
assert groups['tz_minute']
iso_date += '%+03i:%02i' % (
int(groups['tz_hour']), int(groups['tz_minute']))
else:
iso_date += '+00:00'
return iso_date


Expand Down
4 changes: 2 additions & 2 deletions weasyprint/tests/test_pdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -532,7 +532,7 @@ def test_document_info():
<meta name=keywords content="html ,\tcss,
pdf,css">
<meta name=description content="Blah… ">
<meta name=dcterms.created content=2011-04>
<meta name=dcterms.created content=2011-04-21T23:00:00Z>
<meta name=dcterms.modified content=2013-07-21T23:46+01:00>
''').write_pdf(target=fileobj)
info = pdf.PDFFile(fileobj).info
Expand All @@ -543,7 +543,7 @@ def test_document_info():
assert info.get_value('Keywords', '(.*)') == b'(html, css, pdf)'
assert info.get_value('Subject', '(.*)') == (
b'<FEFF0042006C0061006820260020>')
assert info.get_value('CreationDate', '(.*)') == b'(20110401000000)'
assert info.get_value('CreationDate', '(.*)') == b"(20110421230000+00'00)"
assert info.get_value('ModDate', '(.*)') == b"(20130721234600+01'00)"


Expand Down

0 comments on commit 840c4a6

Please sign in to comment.