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.
14 lines
361 B
14 lines
361 B
4 years ago
|
"use strict";
|
||
|
|
||
|
function human_duration_unit(milliseconds) {
|
||
|
let seconds = Math.floor(milliseconds / 1000);
|
||
|
if(seconds <= 60) return "second";
|
||
|
if(seconds <= 60*60) return "minute";
|
||
|
if(seconds <= 60*60*24) return "hour";
|
||
|
if(seconds <= 60*60*24*45) return "day";
|
||
|
if(seconds <= 60*60*24*365) return "month";
|
||
|
return "year";
|
||
|
}
|
||
|
|
||
|
export { human_duration_unit };
|