mirror of
https://github.com/FrankerFaceZ/FrankerFaceZ.git
synced 2025-08-14 01:50:54 +00:00
4.0.0 Beta 1
This commit is contained in:
parent
c2688646af
commit
262757a20d
187 changed files with 22878 additions and 38882 deletions
24
src/utilities/time.js
Normal file
24
src/utilities/time.js
Normal file
|
@ -0,0 +1,24 @@
|
|||
'use strict';
|
||||
|
||||
export function duration_to_string(elapsed, separate_days, days_only, no_hours, no_seconds) {
|
||||
const seconds = elapsed % 60;
|
||||
let minutes = Math.floor(elapsed / 60),
|
||||
hours = Math.floor(minutes / 60),
|
||||
days = '';
|
||||
|
||||
minutes = minutes % 60;
|
||||
|
||||
if ( separate_days ) {
|
||||
days = Math.floor(hours / 24);
|
||||
hours = hours % 24;
|
||||
if ( days_only && days > 0 )
|
||||
return `${days} days`;
|
||||
|
||||
days = days > 0 ? `${days} days, ` : '';
|
||||
}
|
||||
|
||||
return `${days}${
|
||||
(!no_hours || days || hours) ? `${days && hours < 10 ? '0' : ''}${hours}:` : ''
|
||||
}${minutes < 10 ? '0' : ''}${minutes}${
|
||||
no_seconds ? '' : `:${seconds < 10 ? '0' : ''}${seconds}`}`;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue