iamkun / iamkun/dayjs

[BUG] Unable to Parse French Dates in Day.js

Open
#2,379 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**
When attempting to parse a date string in French using Day.js, the parsing fails and returns an "Invalid Date" result.

**To Reproduce**
```javascript
import dayjs from 'dayjs';
import localeData from 'dayjs/plugin/localeData';
import 'dayjs/locale/fr';

dayjs.extend(localeData);

dayjs.locale('fr');
console.log(dayjs.localeData().months());
console.log(dayjs('18 mai 2023').format('YYYY-MM-DD'));
console.log(dayjs('18 mai 2023','D MMMM YYYY').format('YYYY-MM-DD'));
```
**Console Output**
```
(12) ['janvier', 'février', 'mars', 'avril', 'mai', 'juin', 'juillet', 'août', 'septembre', 'octobre', 'novembre', 'décembre']
button.tsx:12 Invalid Date
button.tsx:14 Invalid Date
```
**Expected behavior**
I expected Day.js to correctly parse the French date string "18 mai 2023" and return the formatted date as "2023-05-18".

**Information**
- Day.js Version: [1.11.9]
- OS: [Mac OS]
- Browser: [Chrome 91.0.4472.124]
- Time zone: [e.g. GMT+02:00 DST (Central European Summer Time)]

Please note that the issue occurs specifically when trying to parse French dates, while it seems to work correctly for other languages.

Contributor guide

Open the contributing guide

Research direction

Start by running the reproduction using the localeData plugin and the French locale import shown in the issue, comparing parsing with and without the `D MMMM YYYY` format. Trace the locale-based parsing entry point and verify that `18 mai 2023` formats as `2023-05-18` without producing `Invalid Date`.

Written by the indexing model from the issue text.

Assessment

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