Created
September 27, 2014 08:10
-
-
Save subzey/f5e43254588b04fc7a2a 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
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