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

A range should be considered overlapping even if start and end dates are the same #53

Closed
Zyquivilly opened this issue Sep 23, 2014 · 7 comments

Comments

@Zyquivilly
Copy link

If a range with the same start and end date is within a second range, the overlaps method should return true.

Example:

        var start = new Date(2012, 4, 1)
            , end   = new Date(2012, 4, 23)
            , range = moment().range(start, end);

        var start2 = new Date(2012, 4, 23)
            , end2   = new Date(2012, 4, 26)
            , range2 = moment().range(start2, end2);

        var start3 = new Date(2012, 4, 2)
            , end3   = new Date(2012, 4, 3)
            , range3 = moment().range(start3, end3);

        var start4 = new Date(2012, 4, 2)
            , end4   = new Date(2012, 4, 2)
            , range4 = moment().range(start4, end4);

        console.log(range.overlaps(range2)); // false
        console.log(range.overlaps(range3)); // true
        console.log(range.overlaps(range4)); // should be true
        console.log(range4.overlaps(range)); // should true
@gf3
Copy link
Contributor

gf3 commented Sep 23, 2014

My interval math is rusty, but is this actually the case? I think typically when comparing dates/times intervals are considered open.

@Zyquivilly
Copy link
Author

So in this case then the range 4/2 to 4/2 would essentially be nothing, and therefore can't overlap with anything?

@gf3
Copy link
Contributor

gf3 commented Sep 23, 2014

@ruthmholtrop i suppose it would depend on the precision of the range (i.e.: day, hour, millisecond, etc...).

@mattjacobsen
Copy link

this has just stumped me too.

@vptcnt
Copy link

vptcnt commented Feb 1, 2015

+1

@gf3
Copy link
Contributor

gf3 commented Feb 25, 2015

fixed in 1.0.7

@gf3 gf3 closed this as completed Feb 25, 2015
@gf3
Copy link
Contributor

gf3 commented Feb 25, 2015

screen shot 2015-02-25 at 6 15 14 pm

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

4 participants