Remove the toFriendlyDuration helper
This commit is contained in:
parent
022a63f12f
commit
b19d248bc8
2 changed files with 0 additions and 28 deletions
|
|
@ -2,7 +2,6 @@ import { schemaOptions } from "./schemaOptions.mjs";
|
|||
import { createArray } from "./createArray.mjs";
|
||||
import { detailsExpanded } from "./detailsExpanded.mjs";
|
||||
import { objectValue } from "./objectValue.mjs";
|
||||
import { toFriendlyDuration } from "./toFriendlyDuration.mjs";
|
||||
import { handlebarsLocalizer } from "../utils/localizer.mjs";
|
||||
import { options } from "./options.mjs";
|
||||
|
||||
|
|
@ -11,7 +10,6 @@ export default {
|
|||
// Complex helpers
|
||||
"dd-schemaOptions": schemaOptions,
|
||||
"dd-array": createArray,
|
||||
"dd-toFriendlyDuration": toFriendlyDuration,
|
||||
"dd-objectValue": objectValue,
|
||||
"dd-expanded": detailsExpanded,
|
||||
"dd-i18n": handlebarsLocalizer,
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
const secondsInAMinute = 60;
|
||||
const secondsInAnHour = 60 * secondsInAMinute;
|
||||
|
||||
|
||||
/**
|
||||
* Converts a duration into a more human-friendly format
|
||||
* @param {number} duration The length of time in seconds
|
||||
* @returns The human-friendly time string
|
||||
*/
|
||||
export function toFriendlyDuration(duration) {
|
||||
let friendly = ``;
|
||||
if (duration >= secondsInAnHour) {
|
||||
let hours = Math.floor(duration / secondsInAnHour);
|
||||
friendly += `${hours}h`;
|
||||
duration -= hours * secondsInAnHour;
|
||||
};
|
||||
if (duration >= secondsInAMinute) {
|
||||
let minutes = Math.floor(duration / secondsInAMinute);
|
||||
friendly += `${minutes}m`;
|
||||
duration -= minutes * secondsInAMinute;
|
||||
};
|
||||
if (duration > 0) {
|
||||
friendly += `${duration}s`;
|
||||
};
|
||||
return friendly;
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue