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.

17 lines
412 B

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