iamkun / iamkun/dayjs

chain call functions dayjs、tz、hour、minute return incorrectly

Open
#2,628 0 comments 3 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**
```
const d1 = dayjs('2024-04-09T22:30:50Z').tz("UTC").hour(10).minute(10).format() // '2024-04-09T10:10:50Z'
const value1 = dayjs('2024-04-09T22:30:50Z').tz("UTC").hour(10).minute(10).valueOf() // 1712686250000
const d2 = dayjs(1712686250000).tz("UTC").format() // '2024-04-09T18:10:50Z'

```

**Expected behavior**
excepte d1 === d2

**Information**
- Day.js Version 1.11.10
- OS: MacOs
- Browser : chrome 版本 123.0.6312.107(正式版本) (arm64)
- Time zone: Asia/Shanghai

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the provided dayjs, tz, hour, minute, format, and valueOf chain in a local test. Trace the timezone-related implementation and existing tests to determine why the formatted value and timestamp disagree; done means d1 and d2 produce the same instant and the regression is covered by a test.

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
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.