iamkun / iamkun/dayjs

Month shift when setting month and date manually

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

Describe the bug
When setting a specific year, month, and date manually, the resulting date has a wrong month shift.

Example Code

js
Copy
Edit
import dayjs from 'dayjs';
console.log(dayjs().year(2025).month(0).date(23).format('YYYY-MM-DD'));
// Expected: 2025-01-23
// Got: 2025-02-22
Environment

dayjs version: 1.11.13

Node.js version: 20.19.0

Expected behavior
Setting .month(0) should represent January, not shift into February when .date() is set.

Contributor guide

Open the contributing guide

Research direction

No file or test is named. Start by running the provided Day.js snippet with version 1.11.13 and inspect the behavior of the year(), month(), and date() setters; done means the example formats as 2025-01-23 rather than 2025-02-22.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
backend
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.