iamkun / iamkun/dayjs

1.9.7 Timezone StartOf Possible Regression

Open
#1,275 2 comments 4 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**
With the release of dayJS 1.9.7 we noticed our charts were rendering incorrect data or no data at all. I was able to trace the issue down to dayJS.tz startOf function returning new data between 1.9.6 and 1.9.7 which is a possible side-effect of https://github.com/iamkun/dayjs/pull/1229.

Note: We are attempting to do a conversion from MomentJS -> DayJS so I have included the momentJS result for the same logic.

```
1.9.7:
const start = dayjs.tz('2020-12-15T14:54:51.227', 'Europe/London ').startOf('second').format();
Returns: 2020-12-15T19:54:51+00:00

1.9.6:
const start = dayjs.tz('2020-12-15T14:54:51.227', 'Europe/London').startOf('second').format()
Returns: 2020-12-15T14:54:51+00:00

momentJs
const start = moment.tz('2020-12-15T14:54:51.227', 'Europe/London ').startOf('second').format()
Returns: 2020-12-15T14:54:51Z
```

Upon further inspection of the dayJS object the `$h` variable seems to have changed between the releases which is causing the issue. I'm not 100% sure if this is intended behavior or not and if there is a correct way to achieve the same result as 1.9.6 in 1.9.7 but I figured I would bring attention to the side-effect in case others had a similar result.

One thing to note is that momentJS for the same logic returns the same result as 1.9.6

**Expected behavior**
DayJS startOf would output the same result for startOf across minor releases and / or mimic the result of momentJS.

**Information**
- Day.js Version: 1.9.7 vs 1.9.6
- OS: Mac OS Mojave
- Browser :Google Chrome: Version 87.0.4280.88 (Official Build) (x86_64)
- Time zone: US Eastern Standard Time (EST -5:00)

Contributor guide

Open the contributing guide

Research direction

Start by running the provided dayjs.tz and startOf reproduction with versions 1.9.6 and 1.9.7, then inspect the behavior introduced by pull request 1229. Compare the results with MomentJS and determine whether the changed timezone result is intended; done means the behavior is clarified or corrected with regression coverage.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 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.