iamkun / iamkun/dayjs

Method utc()/format() incorrectly parses the date string 'ddd, MMM D YYYY'

Open
#2,819 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**
If your date string format is 'ddd, MMM D YYYY' than `dayjs.utc()` creates a wrong object, but if you change the format to 'YYYY-MM-DD' it works correctly. Probably it's `format()` issue. Example:
```
dayjs.utc('Fri, Jan 28 2025').format('YYYY-MM-DD') => '2025-01-27'
dayjs.utc('2025-01-28').format('YYYY-MM-DD') => '2025-01-28'
```

**Expected behavior**
This command `dayjs.utc('Fri, Jan 28 2025').format('YYYY-MM-DD')` have to result in `2025-01-28`

**Information**
- Day.js Version 1.11.13
- OS: MacOS
- Browser Chrome 131
- Time zone: GMT+2:00

Contributor guide

Open the contributing guide

Research direction

No file or test is named in the report. Reproduce the two utc() examples first, then locate the relevant parsing and formatting entry points and add coverage for the expected 2025-01-28 result; done means the supplied date string formats to that date without regressing the YYYY-MM-DD case.

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
Quiet
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.