You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
18 lines
412 B
18 lines
412 B
var ms = require('ms');
|
|
|
|
module.exports = function (time, iat) {
|
|
var timestamp = iat || Math.floor(Date.now() / 1000);
|
|
|
|
if (typeof time === 'string') {
|
|
var milliseconds = ms(time);
|
|
if (typeof milliseconds === 'undefined') {
|
|
return;
|
|
}
|
|
return Math.floor(timestamp + milliseconds / 1000);
|
|
} else if (typeof time === 'number') {
|
|
return timestamp + time;
|
|
} else {
|
|
return;
|
|
}
|
|
|
|
}; |