Skip to content

Use UTC for undated Atom entry timestamps - #50

Open
shkyyy18 wants to merge 1 commit into
getpelican:mainfrom
shkyyy18:fix/undated-atom-entry-utc
Open

shkyyy18 wants to merge 1 commit into
getpelican:mainfrom
shkyyy18:fix/undated-atom-entry-utc

Conversation

@shkyyy18

@shkyyy18 shkyyy18 commented Oct 1, 2026

Copy link
Copy Markdown

Bug

For Atom entries without pubdate or updateddate, add_item_elements currently uses naive datetime.now(). rfc3339_date appends Z to naive values. On a UTC+8 machine at 20:34:56 local time, an undated entry therefore reports 20:34:56Z instead of the actual instant 12:34:56Z. The feed-level updated fallback already correctly uses an aware UTC clock.

Minimal fix

Use datetime.datetime.now(tz=datetime.timezone.utc) for the undated entry fallback, matching latest_post_date. Explicit publication/update dates and the public date-formatting function remain unchanged.

Validation

  • Regression tests simulate UTC-5, UTC and UTC+8 host clocks without changing system timezone. They generate/parse a real Atom feed and compare entry and feed updated instants to the same fixed UTC clock.
  • Before fix: 2 failed (non-UTC hosts), 1 passed (UTC control). After fix: all 3 pass.
  • Python 3.12.10 / Windows: baseline 26 passed; after 29 passed, coverage 55% (includes bundled Django compatibility modules and tests, no coverage gate configured).
  • Applicable changed-file pre-commit hooks passed except check-merge-conflict, blocked locally by Windows app-control WinError4551, and pyupgrade, which rewrites an unrelated existing RSS author-formatting line on both unchanged main and the patch. That baseline-only formatting change is deliberately not bundled in this one-line fix. No security policy changes made.
  • Full multi-Python/platform CI matrix not run locally; upstream CI results remain separate.

Checked latest main, existing issues/PRs and repository guidance. AI-assisted investigation, implementation and synthetic test design; stated validation executed locally. No private data or unrelated refactoring.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant