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

2.10.0 has breaking changes to isBefore and isAfter with empty dates #3048

Closed
stijnherreman opened this issue Mar 16, 2016 · 1 comment
Closed

Comments

@stijnherreman
Copy link

After upgrading from 2.8.2 to 2.12.0, I noticed breaking changes to isBefore and isAfter in 2.10.0 and one ore more versions between 2.10.0 and 2.12.0

Test case on Firefox 44.0.2:

var emptyDateIsBeforeDateInThePast = moment("", "DD-MM-YYYY").isBefore(moment("2016-01-01"));
var emptyDateIsBeforeToday = moment("", "DD-MM-YYYY").isBefore(moment("2016-03-16"));
var emptyDateIsBeforeDateInTheFuture = moment("", "DD-MM-YYYY").isBefore(moment("2016-12-31"));
var emptyDateIsAfterDateInThePast = moment("", "DD-MM-YYYY").isAfter(moment("2016-01-01"));
var emptyDateIsAfterToday = moment("", "DD-MM-YYYY").isAfter(moment("2016-03-16"));
var emptyDateIsAfterDateInTheFuture = moment("", "DD-MM-YYYY").isAfter(moment("2016-12-31"));

console.log("emptyDateIsBeforeDateInThePast", emptyDateIsBeforeDateInThePast);
console.log("emptyDateIsBeforeToday", emptyDateIsBeforeToday);
console.log("emptyDateIsBeforeDateInTheFuture", emptyDateIsBeforeDateInTheFuture);
console.log("emptyDateIsAfterDateInThePast", emptyDateIsAfterDateInThePast);
console.log("emptyDateIsAfterToday", emptyDateIsAfterToday);
console.log("emptyDateIsAfterDateInTheFuture", emptyDateIsAfterDateInTheFuture);

Output on 2.8.2:

emptyDateIsBeforeDateInThePast true
emptyDateIsBeforeToday true
emptyDateIsBeforeDateInTheFuture true
emptyDateIsAfterDateInThePast false
emptyDateIsAfterToday false
emptyDateIsAfterDateInTheFuture false

Output on 2.9.0:

emptyDateIsBeforeDateInThePast true
emptyDateIsBeforeToday true
emptyDateIsBeforeDateInTheFuture true
emptyDateIsAfterDateInThePast false
emptyDateIsAfterToday false
emptyDateIsAfterDateInTheFuture false

Output on 2.10.0

emptyDateIsBeforeDateInThePast false
emptyDateIsBeforeToday false
emptyDateIsBeforeDateInTheFuture true
emptyDateIsAfterDateInThePast true
emptyDateIsAfterToday false
emptyDateIsAfterDateInTheFuture false

Output on 2.12.0

emptyDateIsBeforeDateInThePast false
emptyDateIsBeforeToday false
emptyDateIsBeforeDateInTheFuture false
emptyDateIsAfterDateInThePast false
emptyDateIsAfterToday false
emptyDateIsAfterDateInTheFuture false

2.10.0 immediately follows 2.9.0, and this is the changelog for 2.10.0:

Ported code to es6 modules

It's a little late to do anything about this now, and I'll adapt the broken code to work properly with the latest version. However, I do not understand how there can be any functional change at all in 2.10.0

I think a warning in the changelog would be useful, to indicate that even though it's supposed to be refactoring only, there are an unknown number of breaking changes.

@mattjohnsonpint
Copy link
Contributor

Comparison of invalid moments was an edge case that had not been tested properly in previous releases. There was no behavioral contract that "" was either greater than or less than or equal to some other valid moment or some other invalid moment. There were multiple bugs reported on this, and we fixed them. I don't consider this a breaking change.

See #2624, #2619, #2438, #2370, #2462, #2354, #2819, and I'm sure there are a few more.
The changelog does indeed call this out in versions 2.10.5 (#2438 Fix inconsistent moment.min and moment.max results) and 2.11.0 (#2624 Proper handling of invalid moments).

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

No branches or pull requests

2 participants