Skip to content

Preserve fixed-width year formatting tokens - #1067

Open
FanWu-ai wants to merge 1 commit into
python-pendulum:masterfrom
FanWu-ai:fix/padded-year-format-tokens
Open

FanWu-ai wants to merge 1 commit into
python-pendulum:masterfrom
FanWu-ai:fix/padded-year-format-tokens

Conversation

@FanWu-ai

Copy link
Copy Markdown
Contributor

Summary

For years below 1000, YYYY is not padded and YY slices an unpadded decimal year. For example, year 1 formats as "1" and "", while year 100 formats as "100" and "0". These strings lose the advertised year-token widths and can break date serialization.

Format YYYY as four digits and YY as the last two digits with zero padding. Keep the unpadded Y token unchanged. Tests cover year boundaries from 1 to 9999, full-date formatting/parsing roundtrips, localized long formats and escaped literals. Document the supported early-year output.

Verification

Linux x86_64 / CPython 3.12.14, upstream e06dacedc4cdea90fa1286b3965d180ab94cf251:

  • Pristine full suite: 1,871 passed, 3 skipped with both pure-Python and newly built native Rust backends.
  • Final regression tests against pristine source: 8 failed, 3 passed.
  • Fixed full suite: 1,882 passed, 3 skipped with each backend (11 new regression/control cases).
  • Full Mypy: passed across 229 files.
  • prek run --all-files: all six hooks passed, including Ruff and Rust formatting/clippy.
  • mkdocs build --strict -f docs/mkdocs.yml: passed; the same six pre-existing informational anchor notices appear on the pristine build.
  • git diff --check: passed.
  • Additional independent checks: all 9,999 supported years checked for widths, unchanged Y and roundtrips passed.

The unchanged skips are one Windows-only test and two existing unsupported zoneinfo POSIX-transition cases. Native-extension loading was verified. Other operating systems and Python versions were not tested locally. Hosted CI is not claimed passed.

Pull Request Check List

  • Added tests for changed code.
  • Updated documentation for changed code.

Prepared and tested with OpenAI Codex assistance, including automated review. No human review is claimed.

@FanWu-ai
FanWu-ai marked this pull request as ready for review October 20, 2026 21:40
@codspeed

codspeed Bot commented Oct 20, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

ℹ️ 1 benchmark has no flamegraph

The flamegraph could not be generated because we failed to resolve the symbols in the profiling trace. This happens when we fail to harvest information about language frames.

✅ 1 untouched benchmark


Comparing FanWu-ai:fix/padded-year-format-tokens (339ba74) with master (e06dace)

Open in CodSpeed

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