iamkun / iamkun/dayjs

Converting longform Lithuanian date does not work for December

Open
#2,610 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**
I am trying to parse Lithuanian (LT) date in longform. I notice a weird behaviour where dates for every month work correctly apart from December. I have set advancedFormat, customParseFormat as well as LT locale.

So for the following date it works as expected (as well as any other month apart from december):
```js
const august = dayjs('2023 m. rugpjūčio 10 d.', ['YYYY [m.] MMMM D [d.]'], 'lt', true);
/**
Output:
{
'$L': 'lt',
'$u': undefined,
'$d': 2023-08-09T21:00:00.000Z,
'$y': 2023,
'$M': 7,
'$D': 10,
'$W': 4,
'$H': 0,
'$m': 0,
'$s': 0,
'$ms': 0,
'$x': {},
'$isDayjsObject': true
}
**/
```

But the following date is invalid (I have tried with both `gruodžio` and `gruodis`:
```js
const december = dayjs('2023 m. gruodžio 10 d.', ['YYYY [m.] MMMM D [d.]'], 'lt', true);
/**
Output:
{
'$L': 'en',
'$u': undefined,
'$d': Invalid Date,
'$x': {},
'$isDayjsObject': true
}
**/
```

On the other hand I have tried to format a date in December to LT format and it works as expected:
```js
console.log(dayjs('2023-12-10').format('LL')); // Output is "2023 m. gruodžio 10 d."
```

**Expected behavior**
December date in LT should be correctly parsed to dayjs date.

**Information**
- Day.js Version 1.11.10

Contributor guide

Open the contributing guide

Research direction

Start with the supplied Day.js reproduction using the Lithuanian locale, customParseFormat, advancedFormat, and the `YYYY [m.] MMMM D [d.]` format. Compare parsing of `gruodžio` with the months that work and verify that the expected result is a valid December date while existing Lithuanian formatting remains unchanged.

Written by the indexing model from the issue text.

Assessment

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