-
Notifications
You must be signed in to change notification settings - Fork 7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Calling moment.utc("2016-07-01").year(2013).toString() provides the wrong date #4238
Calling moment.utc("2016-07-01").year(2013).toString() provides the wrong date #4238
Comments
In version 2.19.0 the function set$1() was changed. Because of this change, setting a new year for a leap year moment, it always sets the last day of the month as date.
Current (incorrect) implementation
Because the special case is only needed for th 29th of Februar in leap years, the correct implementation should be:
Because this is a critical error it should be corrected as soon as possible. |
sorry just noticed i wrote "I can confirm that this is not an issue previous to moment 1.19.0+. It only is an issue from 1.19.0+" but I actually meant 2.19... ive updated this in the original post |
@HolgerFrank Would you mind submit a PR with your change to fix this? It's a pretty critical bug which should be fixed asap.. Edit: I submitted the PR, couldn't wait. |
Closing in favor of PR. |
Description of the Issue and Steps to Reproduce:
It seems like when setting the date to a date in the past and then setting the year to anything will push the outputted date to be at the end of the month.
If you call
moment.utc("2016-07-01").year(2013).toString()
you will getWed Jul 31 2013 00:00:00 GMT+0000
. Notice how it is Jul 31 and not Jul 01.Environment:
I've reproduced this in Chrome 61 as well as in Node 5.10.1
Other information that may be helpful:
This seems to only be an issue if you are using a date from the year 2016. If you try
moment.utc("2015-07-01").year(2013).toString()
it works fine.I can confirm that this is not an issue previous to moment 2.19.0+. It only is an issue from 2.19.0+
If you are reporting an issue, please run the following code in the environment you are using and include the output:
The text was updated successfully, but these errors were encountered: