Skip to content
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

Date with year 1988 doesn't work correctly when setting year #4274

Closed
daxhuiberts opened this issue Oct 27, 2017 · 4 comments
Closed

Date with year 1988 doesn't work correctly when setting year #4274

daxhuiberts opened this issue Oct 27, 2017 · 4 comments
Labels

Comments

@daxhuiberts
Copy link

Description of the Issue and Steps to Reproduce:

When I have a moment object of which the year is 1988 (e.g. moment("1988-02-10")) and I change the year (e.g. date.year(2017)). Then the day of month is always changed to the last day of the month.

Environment:

Chrome Version 61.0.3163.100 (Official Build) (64-bit) on MacOS Sierra Version 10.12.6.
Examples can be run on the javascript console on the momentjs homepage.

Some incorrect examples::

moment("1988-02-10").year(1999).toString() // => "Sun Feb 28 1999 00:00:00 GMT+0100"
moment("1988-09-25").year(2017).toString() // => "Sat Sep 30 2017 00:00:00 GMT+0200"

Some good working examples:

moment("1989-02-10").year(1999).toString() // => "Wed Feb 10 1999 00:00:00 GMT+0100"
moment("1987-09-25").year(2017).toString() // => "Mon Sep 25 2017 00:00:00 GMT+0200"
@emilebosch
Copy link

It happens with all leap years, not just 1988.

@emilebosch
Copy link

so the original use case was that we wanted to calculate the next birthday of the user. It yielded incorrect results

@mattjohnsonpint
Copy link
Contributor

Dup #4258. Will track there. Thanks.

@mattjohnsonpint
Copy link
Contributor

Actually, dup #4024 and fix pending in #4255.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants