stockshark-util
Advanced tools
Comparing version 1.0.442 to 1.0.443
{ | ||
"name": "stockshark-util", | ||
"version": "1.0.442", | ||
"version": "1.0.443", | ||
"description": "util", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
const moment = require("moment-timezone") | ||
const intervals = require("./consts/intervals") | ||
const util = require("./util") | ||
@@ -114,2 +115,23 @@ //Summer (EDT), UTC -4 currently in use | ||
toHumanizedElapsedTime(start) { | ||
if (!util.isNumber(start)) return "" | ||
return moment().subtract(moment().diff(start, "seconds"), "seconds").fromNow() | ||
} | ||
toHumanizedDuration(seconds) { | ||
if (!util.isNumber(seconds)) return "" | ||
const duration = moment.duration(seconds, "seconds") | ||
if (duration.asSeconds() < 60) { | ||
return Math.round(duration.asSeconds()) + " seconds" | ||
} else if (duration.asMinutes() < 60) { | ||
return Math.round(duration.asMinutes()) + " minutes" | ||
} else if (duration.asHours() < 24) { | ||
return duration.asHours().toFixed(1) + " hours" | ||
} else { | ||
return duration.asDays().toFixed(1) + " days" | ||
} | ||
} | ||
nowET() { | ||
@@ -116,0 +138,0 @@ return this.nowETDate().valueOf() |
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
137420
4942