-
Notifications
You must be signed in to change notification settings - Fork 9
Open
Description
It doesn't seem to be possible to support micro relative timestamps. e.g. 4d 2h 5y 1m 6s
These are quite common in a variety of cases and with other libraries (e.g. timeago).
e.g.
const microTimeSince(date) {
let seconds = Math.floor((new Date() - date) / 1000)
let interval = seconds / 31536000
if (interval > 1) {
return Math.floor(interval) + "y"
}
interval = seconds / 2592000
if (interval > 1) {
return Math.floor(interval) + "m"
}
interval = seconds / 86400
if (interval > 1) {
return Math.floor(interval) + "d"
}
interval = seconds / 3600
if (interval > 1) {
return Math.floor(interval) + "h"
}
interval = seconds / 60
if (interval > 1) {
return Math.floor(interval) + "m"
}
return Math.floor(seconds) + "s"
}
Metadata
Metadata
Assignees
Labels
No labels