iamkun / iamkun/dayjs

using utcOffset setter with keepLocalTime = true results in inconsistent date

Open
#1,412 1 comment 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**
if .utcOffset setter is called with the second param (keepLocalTime) set to true weird things start to happen:

- the toString() function will return incorrect results.
- diff() function will work incorrectly
- the format() function however returns the **correct** result

Reproduction on dayjs website in chrome js console:

![image](https://user-images.githubusercontent.com/12735493/110679247-8be62680-81d7-11eb-86e5-534e5376919d.png)

**Expected behavior**
The format and toString functions should return consistent results, being the same date, diff should return zero.

**Information**
- OS: Windows
- Browser Chrome 88.0.4324.190
- Time zone: CET

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the utcOffset call with keepLocalTime set to true in the Day.js website Chrome console, then compare the outputs of toString(), diff(), and format(). Done means the date representations are consistent and diff() returns zero for the reproduced case.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.