Skip to content

Fix UTC offset formatting in PDF and PGF datetime metadata - #32632

Open
aryany3101 wants to merge 1 commit into
matplotlib:mainfrom
aryany3101:fix/pdf-utc-offset
Open

aryany3101 wants to merge 1 commit into
matplotlib:mainfrom
aryany3101:fix/pdf-utc-offset

Conversation

@aryany3101

Copy link
Copy Markdown

PR summary

Closes #32630

Fixes timezone offset formatting in _datetime_to_pdf:

  • Corrects minutes calculation from seconds ((total_seconds % 3600) // 60).
  • Corrects offset resolution for naive datetimes using d.astimezone().utcoffset().
  • Fixes sign handling for timezone-aware datetimes.
  • Adds unit test covering UTC (Z), positive offsets (e.g. IST +05:30), negative offsets (e.g. EST -05:00), and naive local time.

AI Disclosure

AI assistance was used to analyze the issue and verify the timezone arithmetic formulas. The code implementation and test cases were verified locally.

PR quality check

  • Code follows PEP 8 and project conventions
  • New unit tests added and passing

@github-actions

Copy link
Copy Markdown

Thank you for opening your first PR into Matplotlib!

If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process.

You can also join us on discourse chat for real-time discussion.

For details on testing, writing docs, and our review process, please see the developer guide.
Please let us know if (and how) you use AI, it will help us give you better feedback on your PR.

We strive to be a welcoming and open project. Please follow our Code of Conduct.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: PDF and PGF CreationDate/ModDate carry the wrong UTC offset

1 participant