Skip to content

Normalize SOURCE_DATE_EPOCH in existing timestamp consumers - #14776

Open
Darlokt wants to merge 3 commits into
sphinx-doc:masterfrom
Darlokt:source-date-epoch-consumers
Open

Darlokt wants to merge 3 commits into
sphinx-doc:masterfrom
Darlokt:source-date-epoch-consumers

Conversation

@Darlokt

@Darlokt Darlokt commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

Purpose

Hej,
as requested by @AA-Turner, here is the first of 3 more reviewable split up of the main PR #14770 targeting the SOURCE_DATE_EPOCH behavior and related fixes.

The consumers currently parse the variable independently, with different behavior for empty values, epoch zero, and invalid input. This change introduces a shared parser and uses it in date formatting, EPUB metadata, gettext, and copyright handling. Unset and empty values are treated as absent, and 0 is a valid timestamp. Non-empty values must match -?[0-9]+: leading zeros are accepted, while whitespace, plus signs, underscores, non-ASCII digits, and fractional values are rejected. With this it changes accepted input and is not solely a refactor.

Gettext calculates its timestamp when the builder initializes instead of when its module is imported. Separate builds in the same process can therefore use different epochs, while each builder retains a single timestamp for its output.

Copyright %Y placeholders use the epoch's UTC year directly, capped at the current local year. Substitution works independently of surrounding punctuation, including 2000–%Y, Alice. Existing restrictions on correcting static copyright years are preserved and documented.

The change includes tests, documentation, and a changelog entry. The cache invalidation and Docutils compatibility changes from the original PR are covered by parts 2 and 3. For a more info on the reasoning, see the original PR, for a clean merge and CI testing I still recommend merging #14770, when everything is ironed out.

References

AI Disclosure

OpenAI Codex assisted with splitting up #14770. All AI-assisted work was reviewed and understood by me.

@Darlokt
Darlokt force-pushed the source-date-epoch-consumers branch from 5a86e55 to b33f398 Compare October 24, 2026 12:35
@Darlokt

Darlokt commented Oct 24, 2026

Copy link
Copy Markdown
Contributor Author

The force push was to rebase, for a cleaner diff.

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