Closed mathpere closed 9 years ago
Yeah, I can confirm. Looks like a bug in xor
(which difference
uses internally):
> var range1 = moment('Fri Jun 05 2015 10:30:00 GMT+0200').twix('Fri Jun 12 2015 06:00:00 GMT+0200');
> var range2 = moment('Fri Jun 05 2015 09:30:00 GMT+0200').twix('Fri Jun 05 2015 10:30:00 GMT+0200');
> var range3 = moment('Fri Jun 05 2015 09:30:00 GMT+0200').twix('Fri Jun 05 2015 10:29:00 GMT+0200');
> range1.xor(range2).map(function(r){return r.format();});
[ 'Jun 5, 3:30 AM - Jun 12, 12 AM' ]
> range1.xor(range3).map(function(r){return r.format();});
[ 'Jun 5, 3:30 - 4:29 AM',
'Jun 5, 4:30 AM - Jun 12, 12 AM' ]
I don't have time to dig into it right now, but I'm guessing there's something wrong with this line: https://github.com/icambron/twix.js/blob/develop/src/twix.coffee#L205. I'll see if I can set aside some time to debug it, but it might be a bit. Feel free to take a crack at it!
Fixed in the develop branch, will be in the next release. Thanks for the bug report!
Hi!
First of all, thanks for this very useful library!
I met some unexpected issue with twix.js.
I was expected the following result array:
But I get this result:
Twix.js totally skips the first difference.
If I change the first difference argument by +1 minute as following:
I get this expected result:
If I change the first difference argument by -1 minute as following:
I get this expected result:
So this issue happens when one of the difference arguments has exactly the same date.
Can you confirm my observations?