iamkun / iamkun/dayjs

CustomParseFormat plugin does not work correctly when passing date in Vietnamese locale (vi)

Open
#2,349 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**
CustomParseFormat plugin does not work correctly when passing date in Vietnamese locale. I am trying to convert a date in Vietnamese locale. It is giving 'Invalid date' object.

**Expected behavior**
It should parse the date correctly.

**Information**
- Day.js Version [1.11.8]
- OS: [iOS]
- Browser [chrome 114.0]
- Time zone: Any time zone

Analysis:

In CustomParseFormat plugin, we are having a below regex which strips the numbers from the input. And then it is trying to validate it and showing as 'Invalid Date'

`const matchWord = /\d*[^-_:/,()\s\d]+/ // Word`

In my case, I am trying to pass the input with Vietnamese locale like below and getting invalid date object.

`dayjs("01 Th09, 2019", 'DD MMM, YYYY')`

image

We should remove this decimal check for months (MMM) regex in the expressions object to make it work properly.

image

Attaching the vietnamese locales screenshot below.

image

Contributor guide

Open the contributing guide

Research direction

Start in the CustomParseFormat plugin at the matchWord regex and the expressions object described in the issue. Reproduce the failure with dayjs("01 Th09, 2019", 'DD MMM, YYYY') under the Vietnamese locale, then verify that the date parses correctly without breaking other month formats.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.