summaryrefslogtreecommitdiffstats
path: root/src/gui/painting/qpdf.cpp
diff options
context:
space:
mode:
authorAshish Kulkarni <kulkarni.ashish@gmail.com>2016-11-26 15:12:33 +0530
committerAshish Kulkarni <kulkarni.ashish@gmail.com>2016-12-07 09:53:17 +0000
commitb5c273cb1a92d6b0554aff4577d80b9b4a84e078 (patch)
tree069e47b3eac37b9337c748181604efc59dcabe2f /src/gui/painting/qpdf.cpp
parent062be102283d39bf0cc2b49fbc2e21d48f79ea42 (diff)
generate PDF CreationDate in local time as per PDF specification
According to section 3.8.2, pg 100 of the PDF 1.4 reference [1]: PDF defines a standard date format, which closely follows that of the international standard ASN.1 (Abstract Syntax Notation One), defined in ISO/IEC 8824 (see the Bibliography). A date is a string of the form (D:YYYYMMDDHHmmSSOHH'mm') Whether or not the time zone is known, the rest of the date should be specified in local time. [1] https://partners.adobe.com/public/developer/en/pdf/PDFReference.pdf Change-Id: Ib375d587f983d9c70d995157f95d6a59dca037a5 Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/gui/painting/qpdf.cpp')
-rw-r--r--src/gui/painting/qpdf.cpp13
1 files changed, 11 insertions, 2 deletions
diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp
index 84e18a64dd..7b8bae1642 100644
--- a/src/gui/painting/qpdf.cpp
+++ b/src/gui/painting/qpdf.cpp
@@ -1504,16 +1504,25 @@ void QPdfEnginePrivate::writeInfo()
printString(creator);
xprintf("\n/Producer ");
printString(QString::fromLatin1("Qt " QT_VERSION_STR));
- QDateTime now = QDateTime::currentDateTimeUtc();
+ QDateTime now = QDateTime::currentDateTime();
QTime t = now.time();
QDate d = now.date();
- xprintf("\n/CreationDate (D:%d%02d%02d%02d%02d%02d)\n",
+ xprintf("\n/CreationDate (D:%d%02d%02d%02d%02d%02d",
d.year(),
d.month(),
d.day(),
t.hour(),
t.minute(),
t.second());
+ int offset = now.offsetFromUtc();
+ int hours = (offset / 60) / 60;
+ int mins = (offset / 60) % 60;
+ if (offset < 0)
+ xprintf("-%02d'%02d')\n", -hours, -mins);
+ else if (offset > 0)
+ xprintf("+%02d'%02d')\n", hours , mins);
+ else
+ xprintf("Z)\n");
xprintf(">>\n"
"endobj\n");
}