iamkun / iamkun/dayjs

When the timezone plugin is used With the Mutable plugin, The operation methods of dayjs will fail.

Open
#2,040 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**
```js
dayjs.extend(dayjs_plugin_utc)
dayjs.extend(dayjs_plugin_timezone)
dayjs.extend(dayjs_plugin_badMutable)

dayjs.tz.setDefault('Etc/GMT-9'); // Offset 540 minutes
const now = new Date(); // Beijing time today 13:38

// ✅ correct
dayjs.tz(now).format('YYYY-MM-DD HH:mm') // 2022-08-25 14:38

// ❌ incorrect
dayjs.tz(now).add(-1, 'day').format('YYYY-MM-DD HH:mm') // 2022-08-25 13:38
```

**Expected behavior**

```js
dayjs.tz(now).add(-1, 'day').format('YYYY-MM-DD HH:mm') // 2022-08-24 14:38
```

**Information**
- Day.js Version: v1.11.4
- OS: MacOS
- Browser: Chrome 104.0.5112.101 (x86_64)
- Time zone: GMT+8 CST(Asia/Shanghai)

Contributor guide

Open the contributing guide

Research direction

Reproduce the failure with the utc, timezone, and badMutable plugins and the `dayjs.tz(now).add(-1, 'day')` operation shown in the issue. Compare the formatted result with the expected previous-day time and trace the affected operation methods; done means the operation returns `2022-08-24 14:38` for the supplied scenario.

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
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.