Skip to content

Instantly share code, notes, and snippets.

@subzey
Created September 27, 2014 08:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save subzey/f5e43254588b04fc7a2a to your computer and use it in GitHub Desktop.
Save subzey/f5e43254588b04fc7a2a to your computer and use it in GitHub Desktop.
var toMs = (function (){
function _add(a, b){
var v = new Number((a || 0) + (b || 0));
v.milliseconds = milliseconds;
v.seconds = seconds;
v.minutes = minutes;
v.hours = hours;
v.days = days;
return v;
}
function milliseconds(v){
return _add(+this, +v);
}
function seconds(v){
return _add(+this, v * 1e3);
}
function minutes(v){
return _add(+this, v * 6e4);
}
function hours(v){
return _add(+this, v * 36e5);
}
function days(v){
return _add(+this, v * 864e5);
}
return {
milliseconds: milliseconds,
seconds: seconds,
minutes: minutes,
hours: hours,
days: days
}
})();
if (typeof module !== 'undefined' && module.exports){
module.exports = toMs;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment