2024-08-04 19:52:52 +02:00
|
|
|
const ms = require('ms')
|
2022-07-07 01:45:43 +02:00
|
|
|
|
|
|
|
module.exports = function (time, iat) {
|
2024-08-04 19:52:52 +02:00
|
|
|
var timestamp = iat || Math.floor(Date.now() / 1000)
|
2022-07-07 01:45:43 +02:00
|
|
|
|
|
|
|
if (typeof time === 'string') {
|
2024-08-04 19:52:52 +02:00
|
|
|
var milliseconds = ms(time)
|
2022-07-07 01:45:43 +02:00
|
|
|
if (typeof milliseconds === 'undefined') {
|
2024-08-04 19:52:52 +02:00
|
|
|
return
|
2022-07-07 01:45:43 +02:00
|
|
|
}
|
2024-08-04 19:52:52 +02:00
|
|
|
return Math.floor(timestamp + milliseconds / 1000)
|
2022-07-07 01:45:43 +02:00
|
|
|
} else if (typeof time === 'number') {
|
2024-08-04 19:52:52 +02:00
|
|
|
return timestamp + time
|
2022-07-07 01:45:43 +02:00
|
|
|
} else {
|
2024-08-04 19:52:52 +02:00
|
|
|
return
|
2022-07-07 01:45:43 +02:00
|
|
|
}
|
2024-08-04 19:52:52 +02:00
|
|
|
}
|