This Gist was automatically created by Carbide, a free online programming environment.
Created
March 6, 2017 18:07
-
-
Save carbide-public/e598cebefcb07438d170038ba6e6277b to your computer and use it in GitHub Desktop.
untitled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Event{ | |
from | |
to | |
description | |
constructor(from, to, description ){ | |
this.from = from; | |
this.to = to; | |
this.description = description | |
} | |
} | |
var isConflicting = (event1, event2) => { | |
if( event1.from.getTime() <= event2.from.getTime() && event1.to.getTime() >= event2.from.getTime()){ | |
return true; | |
} | |
if( event1.from.getTime() <= event2.to.getTime() && event1.to.getTime() >= event2.to.getTime() ){ | |
return true; | |
} | |
if( event2.from.getTime() <= event1.to.getTime() && event2.to.getTime() >= event1.to.getTime() ){ | |
return true; | |
} | |
if( event2.from.getTime() <= event1.to.getTime() && event2.to.getTime() >= event1.to.getTime() ){ | |
return true; | |
} | |
return false; | |
} | |
var events = []; | |
events.push( | |
new Event( | |
new Date(2017, 1, 23, 15, 0, 0, 0), | |
new Date(2017, 1, 23, 16, 30, 0, 0), | |
"Interview at the Portal" | |
) | |
) | |
events.push( | |
new Event( | |
new Date(2017, 1, 25, 12, 0, 0, 0), | |
new Date(2017, 1, 25, 1, 0, 0, 0), | |
'Lunch with Cindy') | |
) | |
events.push( | |
new Event( | |
new Date(2017, 1, 24, 17, 0, 0, 0), | |
new Date(2017, 1, 24, 17, 30, 0, 0), | |
'Dinner with John') | |
) | |
events.push( | |
new Event( | |
new Date(2017, 1, 24, 11, 0, 0, 0), | |
new Date(2017, 1, 24, 17, 30, 0, 0), | |
'Conference') | |
) | |
events.push( | |
new Event( | |
new Date(2017, 2, 24, 12, 0, 0, 0), | |
new Date(2017, 2, 24, 12, 30, 0, 0), | |
'Test1') | |
) | |
events.push( | |
new Event( | |
new Date(2017, 2, 24, 12, 29, 0, 0), | |
new Date(2017, 2, 24, 12, 30, 0, 0), | |
'Test2') | |
) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment