iamkun / iamkun/dayjs

MONTHS_IN_FORMAT is wrong in locales with ordinals

Open
#1,423 3 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**
In Russian locale (maybe in others too) when using "Do" format [months](https://github.com/iamkun/dayjs/blob/9c20e77caf7b1b5eccf418175203b198d4e29535/src/locale/ru.js#L30) function working incorrectly.
For example:
`dayjs().locale("ru").format("Do MMMM")`
will output "21 март" but correct one is "21 марта".
That's because "format" argument in [months](https://github.com/iamkun/dayjs/blob/9c20e77caf7b1b5eccf418175203b198d4e29535/src/locale/ru.js#L30) function is "21 MMMM" instead of "Do MMMM" and therefore the MONTHS_IN_FORMAT regex does not work properly..
I have not found a reason why ordinal replaced before locale.

**Information**
- Day.js Version [e.g. v1.10.4]

Contributor guide

Open the contributing guide

Research direction

Start with the months function in src/locale/ru.js and trace how format handles the Do MMMM example before that locale function receives its format argument. The fix is complete when dayjs().locale("ru").format("Do MMMM") produces the correct genitive month form, such as "21 марта", with regression coverage added in the relevant formatting tests.

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
Clearly specified
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.