iamkun / iamkun/dayjs

Unexpected result when using isoWeek plugin

Open
#2,228 0 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**
When adding a day to the last day of year, I expect that the isoweek and year will be correctly updated.

```
import dayjs from 'dayjs';
import isoWeek from 'dayjs/plugin/isoWeek.js';
import customParseFormat from 'dayjs/plugin/customParseFormat.js';

dayjs.extend(isoWeek);
dayjs.extend(customParseFormat);

let date = dayjs("31.12.2022", "DD.MM.YYYY");
console.log(date.isoWeek() + "-" + date.year());
date = date.add(1, "day");
console.log(date.isoWeek() + "-" + date.year());
```

Result is:
**52-2022
52-2023**

**Expected behavior**
The isoweek should be 1 and the year should be 2023.

**Information**
- Day.js Version 1.11.7
- OS: iOS
- Time zone: Asia/Bangkok

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.