Skip to content

Instantly share code, notes, and snippets.

@Mmarin95
Last active October 7, 2022 13:07
Show Gist options
  • Save Mmarin95/5f9e315b6b88c25e0a8180b07f007ef7 to your computer and use it in GitHub Desktop.
Save Mmarin95/5f9e315b6b88c25e0a8180b07f007ef7 to your computer and use it in GitHub Desktop.
Check if date range overlaps
var e1start = e1.start.getTime();
var e1end = e1.end.getTime();
var e2start = e2.start.getTime();
var e2end = e2.end.getTime();
return (e1start > e2start && e1start < e2end || e2start > e1start && e2start < e1end);
// Simplified
startA <= endB && endA >= startB
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment