Skip to content

Conversation

@SmartDever02
Copy link

Closes #2987

When subtracting one week from January 4, 2026, the week number was incorrectly calculated as week 1 of 2025 instead of the correct week (52 or 53 depending on locale).

The issue was in the recursive call when diffInWeek < 0. This fix replaces the recursive call with proper calculation based on the previous year's year start.

Contribution by Gittensor, see my contribution statistics at https://gittensor.io/miners/details?githubId=102175066

 iamkun#2987)

When subtracting one week from January 4, 2026, the week number was
incorrectly calculated as week 1 of 2025 instead of the correct week
(52 or 53 depending on locale).

The issue was in the recursive call when diffInWeek < 0. This fix
replaces the recursive call with proper calculation based on the
previous year's year start.

- Fix week calculation for dates before year start week
- Add test cases for issue iamkun#2987
@SmartDever02
Copy link
Author

requesting your reviews @iamkun
cc: @datastructurey

@datastructurey
Copy link

@SmartDever02 @iamkun I modified and submitted a PR based on my understanding; you can take a look. #2990
I'm a newbie and not very familiar with the contribution rules, sorry.

@SmartDever02
Copy link
Author

are you open to contribution or not? please let me know @iamkun

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.

The week number obtained after subtracting one week from January 4, 2026 is incorrect.

2 participants