-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CreationDate metadata shows wrong timezone offset for UTC #1261
Comments
Thank you for reporting this bug @stevesimmons 👍 Your analysis seems accurate to me. Would you like to sumbit a Pull Request in order to fix this? We already have a unit test for this case in |
@allcontributors please add @stevesimmons for bug |
I've put up a pull request to add @stevesimmons! 🎉 |
I noticed that the issue regarding the incorrect timezone offset for the CreationDate metadata (#1261) is marked as open, and I wanted to check if it has been fixed in any recent updates. If it's still open, I would love to contribute to this issue. Could you provide any guidance on how best to proceed or if there are any existing discussions I should review? Thank you! |
Yes, this issue is still open!
Great, you are welcome! A starting point would be to read this page: https://py-pdf.github.io/fpdf2/Development.html Then you could fork this repository, create a dedicated branch (say |
Yes, I am planning to contribute as part of Hacktoberfest!
I created a branch named issue-1261, fixed the PDFDate.serialize() method in fpdf/syntax.py, and ran the unit tests. As expected, the test in test/metadata/test_set_date.py failed, so I regenerated the associated reference PDF file. I also added a mention of this fix in CHANGELOG.md. I’ve submitted the pull request and look forward to your feedback! |
PR #1290 has been merged to fix that. While the fix has not been released in a new version published on Pypi, you can test that it works for you using:
|
Dates such as the PDF metadata's CreationDate have the general format "D:".
The datetime format strings in
PDFDate.serialize()
(included below) are correct for non-UTC: the timezone is shown as "+01'00'" or "-01'00'" for times ahead/behind of UTC.However for UTC, the code in
PDFDate.serialize()
is given on line 318 offpdf.syntax
asf"D:{self.date:%Y%m%d%H%M%SZ%H'%M'}"
. This incorrectly takes the timestamp's hour and seconds as the timezone.I think in this UTC case, the serialized date should either finish at the "Z", or have a timezone of "+00'00'". Printing "Z00'00'" for UTC looks wrong (I've only ever seen "Z" terminated strings", and printing "Z15:22" (my current time) looks very wrong indeed.
The incorrect line of
fpdf.syntax
is here:The text was updated successfully, but these errors were encountered: