File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed
src/areIntervalsOverlapping Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -71,11 +71,11 @@ export function areIntervalsOverlapping(
7171 const [ leftStartTime , leftEndTime ] = [
7272 + toDate ( intervalLeft . start ) ,
7373 + toDate ( intervalLeft . end ) ,
74- ] . sort ( ) ;
74+ ] . sort ( ( a , b ) => a - b ) ;
7575 const [ rightStartTime , rightEndTime ] = [
7676 + toDate ( intervalRight . start ) ,
7777 + toDate ( intervalRight . end ) ,
78- ] . sort ( ) ;
78+ ] . sort ( ( a , b ) => a - b ) ;
7979
8080 if ( options ?. inclusive )
8181 return leftStartTime <= rightEndTime && rightStartTime <= leftEndTime ;
Original file line number Diff line number Diff line change @@ -142,6 +142,14 @@ describe("areIntervalsOverlapping", () => {
142142 assert ( isOverlapping ) ;
143143 } ) ;
144144
145+ it ( 'sort timestamp' , ( ) => {
146+ const result = areIntervalsOverlapping (
147+ { start : '1970-01-01T02:00:00.000Z' , end : '1970-01-01T03:00:00.000Z' } ,
148+ { start : '1969-12-31T23:30:00.000Z' , end : '1970-01-01T02:30:00.000Z' } ,
149+ ) ;
150+ assert ( result ) ;
151+ } )
152+
145153 it ( "returns result for the normalized intervals if the start date of the initial time interval is after the end date" , ( ) => {
146154 const includedIntervalStart = new Date ( 2016 , 10 , 14 ) ;
147155 const includedIntervalEnd = new Date ( 2016 , 10 , 14 ) ;
You can’t perform that action at this time.
0 commit comments