Created
December 20, 2024 06:10
-
-
Save jaimelr/717e7d2e9e4d57ed15379f722ceb2d40 to your computer and use it in GitHub Desktop.
MomentJS Bug
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ## Describe the bug | |
| The docs do specify that the .year() method signature expects a number value, but strings are not outright rejected. | |
| It seems to happen only with the year 2020 and no other leap years. Starting from a moment object with its date set to | |
| 2020-02-29 and then setting the year to '2020' (with a string value) changes the day to 28. | |
| If you pass 2020 as a number, the day stays at 29. If you start off with 2012, 2016, 2024 or 2028 and then set the year to | |
| the same value, string or number, the day stays at 29. It only happens with the year 2020 using a string value. | |
| Expected behavior | |
| The day stays at 29. | |
| ## Repository | |
| https://github.com/moment/moment | |
| ## Version with the bug | |
| 2.24.0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment