iamkun / iamkun/dayjs

Cloning a dayjs instance with utcOffset results in incorrect object

Open
#1,406 0 comments 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

Cloning a dayjs instance with a utcOffset defined results in an object with a different time signature

const test = dayjs.utc('2000-01-01T06:01:02Z').utcOffset(1, true);
console.log(test.format());
const cloned = test.clone();
console.log(cloned.format());

Actual behavior:
2000-01-01T06:01:02+01:00
2000-01-01T01:01:02+01:00

**Expected behavior**
Both objects would have same console output
2000-01-01T06:01:02+01:00
2000-01-01T06:01:02+01:00

**Information**
- Day.js Version 1.10.4
- OS: Windows
- Browser: Chrome Version 88.0.4324.190 (Official Build) (64-bit)
- Time zone: Eastern Standard Time, GMT-5

Contributor guide

Open the contributing guide

Research direction

Reproduce the example using the utc(), utcOffset(), clone(), and format() entry points shown in the issue, comparing the original and cloned values. Trace how the UTC offset and local-time setting are carried during cloning, then add regression coverage for the expected identical formatted output.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.