Skip to content

Parse explicit compact dates with fixed-width fields - #1516

Open
dongyikuan919 wants to merge 1 commit into
python-babel:masterfrom
dongyikuan919:fix/parse-compact-date
Open

dongyikuan919 wants to merge 1 commit into
python-babel:masterfrom
dongyikuan919:fix/parse-compact-date

Conversation

@dongyikuan919

Copy link
Copy Markdown

Fixes #1515.

Parse adjacent fixed-width year, month, and day fields using their positions in an explicit date pattern. This lets parse_date read compact strings produced by format_date, including 01042004 with ddMMyyyy and 20040401 with yyyyMMdd. The compact path validates the field positions, so an out-of-range month raises ParseError. The predefined ISO path and the existing flexible parsing of separated fields continue to use their current rules.

  • Nine regression cases cover fixed-width fields, Unicode digits, padded years, the two-digit year window, and malformed compact input.
  • Full local pytest run on Python 3.11 with the released CLDR 49 data and entry-point metadata yielded 8,299 passed, 3 skipped, and 2 expected failures. Ruff lint and git diff --check passed.

OpenAI Codex assisted with reproduction, implementation, and testing.

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.

parse_date raises IndexError for explicit fixed-width formats without separators

1 participant