Skip to content

Fix POSIX MWD week-of-month and last-weekday normalization - #761

Merged
Manishearth merged 2 commits into
boa-dev:mainfrom
Manishearth:fix-759-narrow
Nov 2, 2026
Merged

Manishearth merged 2 commits into
boa-dev:mainfrom
Manishearth:fix-759-narrow

Conversation

@Manishearth

@Manishearth Manishearth commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

Fixes three off-by-one/boundary errors in MwdForTime:

  • Subtract 1 before dividing day_of_month by 7 so days 7, 14, 21, and 28 stay in their current week block instead of jumping to the next week.
  • Check days_in_month > 28 rather than day_of_month > 28 when populating extra_days so week-5 (last-weekday) POSIX rules are not prematurely clamped to week 4 on days 1..=28.
  • Use day_29 <= last_day in normalize_mwd so 29-day leap-year Februaries (where day_29 == last_day) properly normalize week 5 to week 4 for the other six weekdays.

Fixes #759.

Agent-driven

Fixes three off-by-one/boundary errors in MwdForTime:
- Subtract 1 before dividing day_of_month by 7 so days 7, 14, 21, and 28 stay in their current week block instead of jumping to the next week.
- Check days_in_month > 28 rather than day_of_month > 28 when populating extra_days so week-5 (last-weekday) POSIX rules are not prematurely clamped to week 4 on days 1..=28.
- Use day_29 <= last_day in normalize_mwd so 29-day leap-year Februaries (where day_29 == last_day) properly normalize week 5 to week 4 for the other six weekdays.

Fixes boa-dev#759.
@Manishearth
Manishearth enabled auto-merge (squash) November 1, 2026 10:54

@jedel1043 jedel1043 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks!

@jedel1043 jedel1043 added the C-bug Something isn't working label Nov 2, 2026
@Manishearth
Manishearth merged commit e304bbb into boa-dev:main Nov 2, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

C-bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PlainDateTime -> ZonedDateTime returns the wrong value in the week before certain DST transitions

3 participants