Dayjs considers Saturday to be the first day of week i.e. date.day() == 0 for Saturday
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
Observe the following code:
```
import dayjs from "dayjs"
enum Days { Sunday =0, Monday, Tuesday, Wednesday, Thursday, Friday, Saturday =6 }
const dt = new Date(2024, 1, 1) // February 1, 2024, Thursday -> 5
const day: Days = Days.Thursday // 5
const diff = dayjs(dt).day() - day
console.log(diff) // -1 because Thursday is 4 in Dayjs
```
It returns a difference of -1, which is only possible when Saturday in dayjs is 0, am I doing something wrong?
- I'm using Ubuntu 23.10,
- my locale is set to Belgium for time,
- Regional Settings is for United States (English)
- I'm running it on a virtual machine. VSCode, Typescript
Contributor guide
Research direction
Start with the supplied TypeScript reproduction using the Day.js day() API and verify the returned value independently of the Ubuntu, locale, and VM settings. Compare the observed day numbering with the library's documented behavior and existing tests; done means either a confirmed bug with a focused regression test or a clarified report showing the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100