The function "format" would be broken after "utcOffset" being invoked twice and more
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
As title. The `format` function would be broken after `utcOffset` being invoked twice and more.
For example:
```
dayjs().format('YYYY-MM-DDTHH:mm:ssZZ')
// 2024-02-17T15:14:51+0800 // Now
dayjs().utcOffset(300).format('YYYY-MM-DDTHH:mm:ssZZ')
// 2024-02-17T12:14:51+0500 // Correct
dayjs().utcOffset(300).utcOffset(300).format('YYYY-MM-DDTHH:mm:ssZZ')
// 2024-02-17T15:14:51+0500 // Wrong
dayjs().utcOffset(300).utcOffset(400).format('YYYY-MM-DDTHH:mm:ssZZ')
// 2024-02-17T16:54:51+0640 // Wrong
dayjs().utcOffset(300).utcOffset(240).utcOffset(120).format('YYYY-MM-DDTHH:mm:ssZZ')
// 2024-02-17T13:14:51+0200 // Wrong
```
But the results of `valueOf` are **all the same**.
**Expected behavior**
The result should be calculated by the last `utcOffset`.
**Information**
- Day.js Version: v1.11.10
- OS: Windows 10
- Browser: Chrome 121.0.6167.185
- Time zone: GMT+8
Contributor guide
Research direction
Reproduce the chained utcOffset examples and compare format with valueOf; start at the format and utcOffset entry points named in the report. Done means format uses the last utcOffset while valueOf remains unchanged, with regression coverage for the shown chains.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100