MCPcopy Index your code
hub / github.com/easydiffusion/easydiffusion / millisecondsToStr

Function millisecondsToStr

ui/media/js/utils.js:186–207  ·  view source on GitHub ↗
(milliseconds)

Source from the content-addressed store, hash-verified

184
185// https://stackoverflow.com/a/8212878
186function millisecondsToStr(milliseconds) {
187 function numberEnding(number) {
188 return number > 1 ? "s" : ""
189 }
190
191 let temp = Math.floor(milliseconds / 1000)
192 let hours = Math.floor((temp %= 86400) / 3600)
193 let s = ""
194 if (hours) {
195 s += hours + " hour" + numberEnding(hours) + " "
196 }
197 let minutes = Math.floor((temp %= 3600) / 60)
198 if (minutes) {
199 s += minutes + " minute" + numberEnding(minutes) + " "
200 }
201 let seconds = temp % 60
202 if (!hours && minutes < 4 && seconds) {
203 s += seconds + " second" + numberEnding(seconds)
204 }
205
206 return s
207}
208
209// https://rosettacode.org/wiki/Brace_expansion#JavaScript
210function BraceExpander() {

Callers 2

getTaskUpdaterFunction · 0.85
onRenderTaskCompletedFunction · 0.85

Calls 1

numberEndingFunction · 0.85

Tested by

no test coverage detected