Created
July 1, 2013 09:01
-
-
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.
This file contains hidden or 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
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
0.start < 1.end && 1.start < 0.end