.add(1, 'month) also changes the day, not just the month
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
Day is changed to the first day of the month
```js
import dayjs from 'dayjs';
import utc from 'dayjs/plugin/utc';
import timezone from 'dayjs/plugin/timezone';
dayjs.extend(utc);
dayjs.extend(timezone);
dayjs.tz.setDefault('UTC');
dayjs.tz('2024-01-15').add(1, 'month').toISOString()
// Expected: '2024-02-15T00:00:00.000Z'
// Actual result: '2024-02-01T00:00:00.000Z'
```
**Information**
- Day.js Version 1.11.10
- OS: Ubuntu 22.04.3 LTS
- Browser Node 20
- Time zone: GMT-03:00, but should use UTC
Contributor guide
Research direction
Start by running the issue's Day.js reproduction with the utc and timezone plugins, then trace the add(1, 'month') path and its month-handling logic. The fix is complete when 2024-01-15 plus one month preserves day 15 and the relevant tests cover the expected UTC ISO output.
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
- 48/100