iamkun / iamkun/dayjs

Dayjs returns next year instead of passed one when trying to parse date

Open
#1,656 4 comments 4 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'm trying to parse some date strings in russian locale, but dayjs returns dates with passed year + 1, e.g. 2020 instead of 2019

```javascript
import dayjs from 'dayjs';
import 'dayjs/locale/ru';
import customParseFormat from 'dayjs/plugin/customParseFormat';

dayjs.locale('ru');
dayjs.extend(customParseFormat);

dayjs('11 декабря 2019', 'DD MMMM YYYY', 'ru').format('DD MMMM YYYY');
dayjs('11 декабря 2018', 'DD MMMM YYYY', 'ru').format('DD MMMM YYYY');
dayjs('11 декабря 2017', 'DD MMMM YYYY', 'ru').format('DD MMMM YYYY');
```

**Expected behavior**
Dayjs returns date with correct year

**Information**
- Day.js Version - 1.10.7
- OS: Windows 10
- Browser: Chrome 94.0.4606.61
- Time zone: GMT+3 (Moscow)

Contributor guide

Open the contributing guide

Research direction

Start by running the provided reproduction with the customParseFormat plugin and the Russian locale, then trace how the locale month name and year are parsed. Add a regression test covering the three shown dates and verify that formatting preserves each input year.

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.