Fix regression: time stamp test suite failures

This commit is contained in:
James R. Barlow
2018-04-17 16:59:21 -07:00
parent 076363d78e
commit 1a516b2af9
2 changed files with 3 additions and 1 deletions
+1
View File
@@ -143,6 +143,7 @@ def decode_pdf_date(s: str) -> datetime:
if s.startswith('D:'):
s = s[2:]
s = s.replace("'", "") # Remove apos from PDF time strings
for fmt in pdfmark_date_fmts:
try:
return datetime.strptime(s, fmt)
+2 -1
View File
@@ -19,6 +19,7 @@
import pytest
import PyPDF2 as pypdf
import datetime
from datetime import timezone
from ocrmypdf.pdfa import file_claims_pdfa, encode_pdf_date, decode_pdf_date
from ocrmypdf.exceptions import ExitCode
@@ -150,6 +151,6 @@ def test_creation_date_preserved(spoof_tesseract_noop, output_type, resources,
# We expect that the modified date is quite recent
date_after = decode_pdf_date(after['/ModDate'])
assert seconds_between_dates(
date_after, datetime.datetime.utcnow()) < 1000
date_after, datetime.datetime.now(timezone.utc)) < 1000