Skip to content

Fix ISO week construction at the minimum supported year - #3464

Open
Shubham-Padkonde wants to merge 1 commit into
spotify:masterfrom
Shubham-Padkonde:fix/iso-week-construction
Open

Shubham-Padkonde wants to merge 1 commit into
spotify:masterfrom
Shubham-Padkonde:fix/iso-week-construction

Conversation

@Shubham-Padkonde

Copy link
Copy Markdown

Week(1, 1) raises OverflowError even though both ends of the interval are valid Python dates. The constructor starts its search ten days before January 1, which underflows before it can find the requested week.

Use datetime.date.fromisocalendar to obtain the Monday directly. This also removes the day-by-day search for ordinary weeks. The seven-day half-open interval is unchanged.

Tests cover the minimum year, weeks crossing calendar-year boundaries, a valid week near the maximum year, and invalid ISO week numbers. The minimum-year regression fails before the change; 264 related date, parameter, and range tests plus seven subtests pass afterward. Ruff and formatting checks pass.

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