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

[bugfix] Inconsistent moment(object) behaviour when using day: 0 (#5097) #5098

Conversation

jnelssonsmith
Copy link
Contributor

As explained in issue #5097 this fixes a bug where moment({day: 0}) was acting differently from day: '0', date: 0 or date: '0'. This is ultimately due to the use of i.day || i.date. When i.day is 0, it is still falsey so it returns i.date which is undefined.

This PR makes the behaviour consistent by explicitly checking whether the key is undefined rather than just falsey.

@jnelssonsmith jnelssonsmith changed the title [Bugfix] Inconsistent moment(object) behaviour when using day: 0 (#5097) [bugfix] Inconsistent moment(object) behaviour when using day: 0 (#5097) May 4, 2019
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.07%) to 88.337% when pulling 8676f75 on jnelssonsmith:bugfix/5097-inconsistent-moment-obj-behaviour-date-day into d0f0dd8 on moment:develop.

@jnelssonsmith
Copy link
Contributor Author

@marwahaha if you could have a squiz at this when you get a chance that would be great 💯

@jnelssonsmith
Copy link
Contributor Author

Or @ichernev @troyastorino 😄

Copy link
Contributor

@harkue harkue left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@ichernev ichernev merged commit 37a7389 into moment:develop Apr 23, 2020
@MartinLoeper
Copy link

@ichernev @jnelssonsmith
Guys, this is a breaking change, isn't it?
We stumbled across this today because our integration tests went red.

Is it possible to at least include this as breaking change in the changelog somehow?

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

Successfully merging this pull request may close these issues.

None yet

5 participants