iamkun / iamkun/dayjs

When setting last day of the month then setting month => first day of next month

Open
#2,294 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**
`dayjs().date(31).month(4)`

i'm just running this in the chrome console
![Capture d’écran 2023-04-21 à 10 28 03](https://user-images.githubusercontent.com/3956660/233586110-b75a0570-decb-4721-845e-270db4906d03.png)

**Expected behavior**
I'm expecting having the 31th of May.

**Workaround**
If i do this `dayjs().month(4).date(31)` it works fine

**Information**
- Day.js Version 1.11.6
- OS: MACos ventura 13.2.1
- Browser Chrome 111 arm
- Time zone: GMT+2

Contributor guide

Open the contributing guide

Research direction

Start by reproducing `dayjs().date(31).month(4)` and compare it with the reported workaround, `dayjs().month(4).date(31)`. Trace the `date()` and `month()` entry points and their existing tests; done means setting the month after the day preserves the expected May 31 date without breaking other month-boundary cases.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.