From 81647dd06fff9f30b1143b1af0917d0b0e7e19d4 Mon Sep 17 00:00:00 2001 From: josch Date: Fri, 13 Mar 2015 13:09:02 +0100 Subject: [PATCH] use common variable for datetime format string --- src/img2pdf.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/img2pdf.py b/src/img2pdf.py index 8b7a1fb..5c30b2b 100755 --- a/src/img2pdf.py +++ b/src/img2pdf.py @@ -95,14 +95,17 @@ class pdfdoc(object): info[b"/Creator"] = b"("+creator+b")" if producer: info[b"/Producer"] = b"("+producer+b")" + + datetime_formatstring = "%Y%m%d%H%M%S" if creationdate: - info[b"/CreationDate"] = b"(D:"+creationdate.strftime("%Y%m%d%H%M%S").encode()+b")" + info[b"/CreationDate"] = b"(D:"+creationdate.strftime(datetime_formatstring).encode()+b")" elif not nodate: - info[b"/CreationDate"] = b"(D:"+now.strftime("%Y%m%d%H%M%S").encode()+b")" + info[b"/CreationDate"] = b"(D:"+now.strftime(datetime_formatstring).encode()+b")" if moddate: - info[b"/ModDate"] = b"(D:"+moddate.strftime("%Y%m%d%H%M%S").encode()+b")" + info[b"/ModDate"] = b"(D:"+moddate.strftime(datetime_formatstring).encode()+b")" elif not nodate: - info[b"/ModDate"] = b"(D:"+now.strftime("%Y%m%d%H%M%S").encode()+b")" + info[b"/ModDate"] = b"(D:"+now.strftime(datetime_formatstring).encode()+b")" + if subject: info[b"/Subject"] = b"("+subject+b")" if keywords: