iamkun / iamkun/dayjs

subtract(years) causes incorrect date when crossing historical timezone change in Malaysia

Open
#3,137 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**
When parsing a date in 2081 and subtracting 100 years to get a date in 1981, the resulting date is incorrect (shifts from Dec 25 to Dec 1, a 24-day difference). This only happens in Malaysia timezone and appears to be related to Malaysia's historical timezone change on December 31, 1981 (UTC+7:30 → UTC+8:00).

**Expected behavior**
After `subtract(100, "years")`, the date should be `1981-12-25` (same day and month as the original date).

**Information**
- **dayjs version**: 1.11.19
- **Plugins**: customParseFormat, utc, timezone
- **Timezone**: Asia/Kuala_Lumpur (UTC+8, but was UTC+7:30 before Jan 1, 1982)
- **Node.js version**:v20.19.3
- **OS**: macOS

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.