iamkun / iamkun/dayjs

.fomat is adding an extra month

Open
#2,209 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**
Bug arises while formatting javascript date object, to reproduce:
- run the following code snippet.
```js
import dayjs from 'dayjs'

const test = new Date('2020-01-01') // '02/01/2022'
const result = dayjs(test).format('DD/MM/YYYY')
```
- Also happen with `new Date(2020, 1, 1)` constructor

**Expected behavior**
`result` should be '01/01/2020', instead I get
![image](https://user-images.githubusercontent.com/67649525/212697429-dee417f6-eaab-4044-8f03-3313c0a6f49b.png)
![image](https://user-images.githubusercontent.com/67649525/212697632-015ecb66-de89-4ac4-9a79-0abfbc7e6c6f.png)

**Information**
- Day.js Version v.1.11.7
- OS: Linux, Pop_OS
- Browser: Brave
- Time zone: GMT-05:00

Contributor guide

Open the contributing guide

Research direction

Start by running the provided JavaScript examples with Day.js v1.11.7 and the stated GMT-05:00 timezone, then inspect the date-formatting behavior involved. Add a regression test for both Date constructors and verify that formatting produces the expected day, month, and year.

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
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.