iamkun / iamkun/dayjs

Problem with getting date of first week of a year 2021

Open
#1,366 9 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**
I want to get date of a first week of 2021 (which is `2020-12-28`).
Dayjs gets `2019-12-30`. Momentjs gets correct date.
Here is my code:
```
dayjs('2021').day(1).week(1).toDate();
moment('2021').day(1).week(1).toDate();
```

**Expected behavior**
Should be `2020-12-28`

**Information**
- Day.js Version `1.10.4`
- Moment.js@2.27.0
- OS: `Windows 10`
- Browser `chrome 62`

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the provided Day.js 1.10.4 snippet and comparing its result with Moment.js. Trace the week calculation used by the .week(1) entry point, then verify that the result for 2021 is 2020-12-28.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.