iamkun / iamkun/dayjs

Cloning a date with a timezone without offset results in a different date

Open
#2,265 0 comments 1 reaction 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**
First of all, thanks for the great library! We’ve found a bug when cloning a date with a timezone without offset. This can easily be replicated with the following test:

```javascript
it('clone retains date and timezone for timezone without offset', () => {
const instance = dayjs('2022-01-01T03:00:00.000Z').tz('Europe/London')
const another = instance.clone()
expect(another.format()).toEqual(instance.format())
})
```

After cloning, the date is not the same as the original one:

```
Expected value to equal:
"2022-01-01T03:00:00Z"
Received:
"2021-12-31T14:00:00Z"
```

**Expected behavior**
Cloning should not change the date when a timezone without offset is used.

**Information**
- Day.js Version v1.11.7
- OS: Linux
- Browser NodeJS
- Time zone: WET +00:00

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.