Skip to content

Fix ISO week-date parsing for years before 1000 - #1078

Closed
ekanshul wants to merge 1 commit into
python-pendulum:masterfrom
ekanshul:fix-1076-week-date-year-padding
Closed

ekanshul wants to merge 1 commit into
python-pendulum:masterfrom
ekanshul:fix-1076-week-date-year-padding

Conversation

@ekanshul

Copy link
Copy Markdown

Pull Request Check List

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

Fixes #1076

_get_iso_8601_week built a strptime string as f"{year}-{ordinal}". %Y needs exactly four digits, so week dates with a year below 1000 (0416-W34-6, 0999-W34-6, 0004-W10-5, basic 0416W346) raised ParserError even though the same years parse as calendar dates.

Zero-pad the year. Existing week dates (2012-W05, 2009-W53-7, …) are unchanged.

strptime %Y matches exactly four digits, so interpolating an unpadded
year made 0416-W34-6 and similar week dates raise ParserError.

Fixes python-pendulum#1076
@Secrus

Secrus commented Nov 15, 2026

Copy link
Copy Markdown
Collaborator

Duplicate #1077

@Secrus Secrus closed this Nov 15, 2026
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() rejects ISO 8601 week dates with years < 1000 (strptime %Y needs zero-padding)

2 participants