Skip to content

Instantly share code, notes, and snippets.

@carbide-public
Created March 6, 2017 18:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save carbide-public/e598cebefcb07438d170038ba6e6277b to your computer and use it in GitHub Desktop.
Save carbide-public/e598cebefcb07438d170038ba6e6277b to your computer and use it in GitHub Desktop.
untitled
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