UTC compare returns wrong result
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
The compare result goes wrong when using `utc` to transform dayjs first.
**Expected behavior**
Works fine with or without using `utc`
**Information**
- Day.js Version 1.8.24
- OS: Mac & Windows
- Browser chrome 80
- Time zone: GMT+0800 (China Standard Time)
```js
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
dayjs.extend(utc)
let formatter = 'YYYY-MM-DD HH:mm:ss'
const result = dayjs('2020-04-23T15:00:00').utc().add(1, 'hour').isAfter(dayjs('2020-04-23T09:00:00'))
console.log(dayjs('2020-04-23T15:00:00').utc().format(formatter))
console.log(dayjs('2020-04-23T09:00:00').format(formatter))
console.log(result) // true. Actuall, it should return false
```
Contributor guide
Research direction
Start by running the supplied reproduction with the dayjs/plugin/utc entry point and compare the UTC-transformed value with the local value. Trace the comparison and add operation involved in the example; done means the reported expression returns false and comparison behavior is consistent with and without utc.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- backend-api-design
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100