iamkun / iamkun/dayjs

dayjs.tz() with day() make a confusing format() output

Open
#2,235 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 set default timezone, and set the day of the week , get a confusing format() output
```js
dayjs.tz.setDefault("Europe/London");

dayjs.tz('2023-02-10 14:00:00').day(3).format() // '2023-02-08T14:00:00Z'
dayjs.tz(dayjs.tz('2023-02-10 14:00:00')).day(3).format() // '2023-02-08T06:00:00Z'
dayjs.tz(dayjs.tz(dayjs.tz('2023-02-10 14:00:00'))).day(3).format() // '2023-02-08T06:00:00Z'
```

**Expected behavior**

**Playground**
https://codesandbox.io/s/focused-cohen-mkylpd

**Information**
- Day.js Version v1.11.7
- OS: windows10
- Browser chrome 109
- Time zone: Asia/Shanghai

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the three examples in the linked CodeSandbox with Day.js v1.11.7 and the reported time zones. The issue does not name source files or tests and leaves Expected behavior blank, so establish the intended output before tracing the timezone and day() behavior. Done means the intended behavior is documented and covered by a regression test.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.