Skip to content

Instantly share code, notes, and snippets.

@IamSilviu
Created July 1, 2013 09:01
Show Gist options
  • Save IamSilviu/5899416 to your computer and use it in GitHub Desktop.
Save IamSilviu/5899416 to your computer and use it in GitHub Desktop.
JavaScript Validation for time overlapping.Returns true if time overlaps, requires a param with start - end time stamp.
var Timestamps = [
{ start: 1360454400000, end: 1360540800000 },
{ start: 1360454400000, end: 1360574700000 },
{ start: 1372668447947, end: 1372668447947 }]
var timeOverlaps = function (Timestamps) {
for (var i = 0; i < Timestamps.length; i++) {
for (var j = i + 1; j < Timestamps.length; j++) {
if ((Timestamps[i].start < Timestamps[j].end) && (Timestamps[j].start < Timestamps[i].end)) {
return true;
}
}
}
return false;
}
@IamSilviu
Copy link
Author

0.start < 1.end && 1.start < 0.end

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment