React-datepicker: Problems with 30 and 31 of december

Created on 9 Jan 2019  路  9Comments  路  Source: Hacker0x01/react-datepicker

Hi.
When i try to choose the 30 or 31 of december, component shows next year.
If you need more information for fix it, i can give it for you.
For example: if I try to choose 30 December 2018 input field shows 30 December 2019, but the value in this field is right 30 December 2018 (I store this in component state)

wontfix

Most helpful comment

FYI this problem can be fixed by using yyyy in your dateFormat instead of YYYY.

Correct: dateFormat="dd/MM/yyyy"
Incorrect: dateFormat="dd/MM/YYYY"

You should do this anyway because on some browsers you get an error trying to use YYYY:

`options.awareOfUnicodeTokens` must be set to `true` to use `YYYY` token; see: https://git.io/fxCyr

All 9 comments

also experiencing this issue. @VSelemanov what version are you using?

We are facing the same issue with version 2.0.0

@Dakkers Hi. I am using react-datepicker 2.0.0. I found one more problem - when i use Date Range (example) if i try to choose right border of range less then left border of range datepicker crashes

I am experiencing the same problem. I have version 2.1.0. I can provide some additional examples that might be helpful in identifying the root cause.

End of 2018: Selecting 30 December 2018 or 31 December 2018, the input field shows the year 2019.

End of 2017: If I choose 31 December 2017, it shows 2018, but if I choose 30 December 2017, it correctly shows 2017.

End of 2016: All dates display correctly.

End of 2015: Dates from 27 December 2015 through 31 December 2015 display incorrectly, but 26 December 2015 is correct.

Summary of the observed pattern: selecting a date in the last week of December (starting on Sunday) will result in an incorrect year being displayed. So if January 1 is Monday, selecting December 31 (Sunday) will show an incorrect year. If January 1 is Tuesday, then both December 30 (Sunday) and December 31 (Monday) will be incorrect. Etc. If January 1 is Saturday, then any date between December 26 (Sunday) and December 31 (Friday) will be incorrect.

In other words, when selecting a date in the last week of the year -- i.e., the bottom row of the calendar -- if January 1 is visible in that calendar row, the year will be incorrectly displayed in the input field.

FYI this problem can be fixed by using yyyy in your dateFormat instead of YYYY.

Correct: dateFormat="dd/MM/yyyy"
Incorrect: dateFormat="dd/MM/YYYY"

You should do this anyway because on some browsers you get an error trying to use YYYY:

`options.awareOfUnicodeTokens` must be set to `true` to use `YYYY` token; see: https://git.io/fxCyr

@danconnell You made my day, thank's!

@danconnell Worked like a charm. Thanks!

FYI this problem can be fixed by using yyyy in your dateFormat instead of YYYY.

Correct: dateFormat="dd/MM/yyyy"
Incorrect: dateFormat="dd/MM/YYYY"

You should do this anyway because on some browsers you get an error trying to use YYYY:

`options.awareOfUnicodeTokens` must be set to `true` to use `YYYY` token; see: https://git.io/fxCyr

It's not work, when I click onChange this error show anyway

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

arturictus picture arturictus  路  3Comments

sarav1234 picture sarav1234  路  3Comments

hoodsy picture hoodsy  路  3Comments

rsouthpaw picture rsouthpaw  路  3Comments

kkras3 picture kkras3  路  3Comments