week() with timezone is incorrect. (Europe/London)
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Performance is inconsistent with momentjs.
see https://codesandbox.io/s/blue-platform-4zlug?file=/src/index.js
```js
console.log(
'dayjs: 2021-01-05',
dayjs.tz('2021-01-05', 'Europe/London').format("gggg-wo"),
dayjs.tz('2021-01-05', 'Europe/London').week()
);
// output
// dayjs: 2021-01-05 2021-6th 6
console.log(
'moment: 2021-01-05',
moment.tz('2021-01-05', 'Europe/London').format("gggg-wo"),
moment.tz('2021-01-05', 'Europe/London').week()
);
// output
// moment: 2021-01-05 2021-2th 2
```
**Expected behavior**
output `dayjs: 2021-01-05 2021-2th 2`
**Information**
- Day.js Version 1.10.7
- OS: MacOs
- Browser chrome 96.0.4664.93
- Time zone: GMT+0800
Contributor guide
Research direction
Start by running the linked CodeSandbox and compare dayjs.tz(..., 'Europe/London').week() and format("gggg-wo") with moment.tz for 2021-01-05. Trace the timezone and week entry points to determine why Day.js returns week 6 instead of 2. Done means the Europe/London example matches the expected Day.js output and the behavior is covered by a regression check.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- web-dev
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100