Created
October 26, 2015 12:40
-
-
Save maxdeepfield/fc1a53e6f71bdbbeaef9 to your computer and use it in GitHub Desktop.
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
// converts HH:ii time to seconds from midnight | |
var timeToSeconds = function(time){ | |
if (time.length != 5) { | |
return false; | |
} | |
var h = Number(time.split(':')[0]); | |
var m = Number(time.split(':')[1]); | |
if (isNaN(h) || isNaN(m)) { | |
return false; | |
} | |
if (h < 0 || h > 23) { | |
return false; | |
} | |
if (m < 0 || m > 59) { | |
return false; | |
} | |
return h*60*60+m*60; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment