Skip to content

Instantly share code, notes, and snippets.

@BrunoQuaresma
Created December 16, 2014 13:19
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 BrunoQuaresma/8358b0cd209ee5f14758 to your computer and use it in GitHub Desktop.
Save BrunoQuaresma/8358b0cd209ee5f14758 to your computer and use it in GitHub Desktop.
Time for JS
function Time(str){
"use strict";
var values = str.split(':'),
seconds = parseInt(values[2]),
minutes = parseInt(values[1]),
hours = parseInt(values[0]);
this.getSeconds = function(){
return seconds;
}
this.getMinutes = function(){
return seconds;
}
this.getHours = function(){
return seconds;
}
this.convertToMiliseconds = function(){
return (seconds + (minutes * 60) + (hours * 60 * 60)) * 1000;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment