iamkun / iamkun/dayjs

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

Open
#2,803 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

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

```typescript
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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.