timespan.js
1 var ms = require('ms'); 2 3 module.exports = function (time, iat) { 4 var timestamp = iat || Math.floor(Date.now() / 1000); 5 6 if (typeof time === 'string') { 7 var milliseconds = ms(time); 8 if (typeof milliseconds === 'undefined') { 9 return; 10 } 11 return Math.floor(timestamp + milliseconds / 1000); 12 } else if (typeof time === 'number') { 13 return timestamp + time; 14 } else { 15 return; 16 } 17 18 };