Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect computation of the week of the year in the case it is 53 #2803

Open
jordi-petit opened this issue Jan 8, 2025 · 1 comment
Open

Comments

@jordi-petit
Copy link

Describe the bug
The week of the year is wrongly computed. Here is an example:

import dayjs from 'dayjs'
import weekOfYear from 'dayjs/plugin/weekOfYear'

dayjs.extend(weekOfYear)

console.log(dayjs('2024-12-28').week()) // ✅
console.log(dayjs('2024-12-29').week()) // ❌ (says 1 but is 53)
console.log(dayjs('2024-12-30').week()) // ❌ (says 1 but is 53)
console.log(dayjs('2024-12-31').week()) // ❌ (says 1 but is 53)
console.log(dayjs('2025-01-01').week()) // ✅

Expected behavior
The weeks for the 29, 30 and 31 of december should be 53, and not 1, as the method returns.

Information

  • DayJS version: 1.11.13
  • OS: MacOS
  • Browser: Chrome, also command line: bun
  • Time zone: CET
@tupe12334
Copy link

tupe12334 commented Jan 11, 2025

According to the weekYear plugin's tests, this is the expected behavior for this function. The function documentation might need an update on this topic.
Please have a look here:

['2020-12-31', 2020],
['2021-01-01', 2020],
['2021-01-02', 2020],
['2021-01-03', 2020],
['2021-01-04', 2021],
['2021-01-05', 2021]

@iamkun Please let us know if that is the expected behavior, if not, let me know and I will fix this bug.

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

No branches or pull requests

2 participants