iamkun / iamkun/dayjs

Date Calculation Issue with Subtracting a Large Number of Years

Open
#2,749 2 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

**Describe the bug**
I've encountered an issue with `dayjs` when subtracting a large number of years from a date. Specifically, when I attempt to subtract 129 years from a date, the resulting date is incorrect.
![image](https://github.com/user-attachments/assets/0b1ec443-333a-444c-b242-407f702b7d93)

**Expected behavior**
The date after subtracting 129 years should accurately reflect the original month and day, not resetting to the first day of the month.

**Information**
- Day.js Version v1.11.12
- OS: Mac OS
- Browser Chrome/129.0.0.0
- Time zone: America/Toronto

Contributor guide

Open the contributing guide

Research direction

No files or tests are named. Reproduce the reported subtraction with Day.js v1.11.12 using a date, a 129-year subtraction, and the America/Toronto timezone, then trace the date-calculation implementation and existing tests. Done means the resulting date preserves the original month and day rather than resetting to the first day of the month.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
web-dev
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.