Incorrect year with localized month in date
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.8k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
When use customParseFormat plugin and localized string with latest month of year e.g. "1 декабря 2023" I'm getting the wrong year (+1).
Base code
```javascript
import dayjs from "dayjs"
import customParseFormat from "dayjs/plugin/customParseFormat"
import "dayjs/locale/ru"
dayjs.extend(customParseFormat)
dayjs.locale("ru")
```
Example
```javascript
//Check various months
console.log("JAN:", dayjs("1 января 2023", "D MMMM YYYY").format("DD.MM.YYYY")); //JAN: 01.01.2023
console.log("NOV:", dayjs("1 ноября 2023", "D MMMM YYYY").format("DD.MM.YYYY")); //NOV: 01.11.2023
console.log("DEC:", dayjs("1 декабря 2023", "D MMMM YYYY").format("DD.MM.YYYY")); //DEC: 01.12.2024
// Check end of year
console.log("END:", dayjs().endOf("year").format("DD.MM.YYYY")); //END: 31.12.2023
```
**Expected behavior**
```javascript
console.log("DEC:", dayjs("1 декабря 2023", "D MMMM YYYY").format("DD.MM.YYYY")); //Must be: 01.12.2023
```
**Information**
- Day.js Version [v1.11.10]
- OS: [macOS Sonoma 14.1]
- Browser [Chrome 119.0.6045.159]
- Time zone: [GMT+7 Novosibirsk/Russia]
Contributor guide
Research direction
Start with the reported reproduction using customParseFormat and the Russian locale, focusing on parsing "1 декабря 2023" with the "D MMMM YYYY" format. Verify the localized December case and the other month examples, then confirm that the result formats as 01.12.2023 without changing the expected behavior for January or November.
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
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100