stockshark-util
Advanced tools
Comparing version 1.0.444 to 1.0.445
{ | ||
"name": "stockshark-util", | ||
"version": "1.0.444", | ||
"version": "1.0.445", | ||
"description": "util", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -120,3 +120,3 @@ const moment = require("moment-timezone") | ||
toHumanizedDuration(seconds) { | ||
toHumanizedDuration(seconds, abbreviate = false) { | ||
if (!util.isNumber(seconds)) return "" | ||
@@ -126,10 +126,17 @@ | ||
const units = { | ||
seconds: abbreviate ? "s" : " seconds", | ||
minutes: abbreviate ? "m" : " minutes", | ||
hours: abbreviate ? "h" : " hours", | ||
days: abbreviate ? "d" : " days", | ||
} | ||
if (duration.asSeconds() < 60) { | ||
return Math.round(duration.asSeconds()) + " seconds" | ||
return Math.round(duration.asSeconds()) + units.seconds | ||
} else if (duration.asMinutes() < 60) { | ||
return Math.round(duration.asMinutes()) + " minutes" | ||
return Math.round(duration.asMinutes()) + units.minutes | ||
} else if (duration.asHours() < 24) { | ||
return duration.asHours().toFixed(1) + " hours" | ||
return duration.asHours().toFixed(1) + units.hours | ||
} else { | ||
return duration.asDays().toFixed(1) + " days" | ||
return duration.asDays().toFixed(1) + units.days | ||
} | ||
@@ -136,0 +143,0 @@ } |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
137646
4948