forgot build
This commit is contained in:
25
dist/timehelper.js
vendored
25
dist/timehelper.js
vendored
@@ -36,18 +36,23 @@ export function calculateSecondsBetween(start, end) {
|
||||
const seconds = Math.max(60, (end - start) / 1000);
|
||||
return {
|
||||
seconds,
|
||||
toReadable: (roundToMinutes) => secondsToReadable(seconds, roundToMinutes),
|
||||
toReadable: (roundToMinutes) => formatSecondsToDHMS(seconds, roundToMinutes),
|
||||
};
|
||||
}
|
||||
export function secondsToReadable(secs, roundToMinutes = false) {
|
||||
export function formatSecondsToDHMS(secs, roundToMinutes = false) {
|
||||
const totalSeconds = roundToMinutes ? Math.round(secs / 60) * 60 : secs;
|
||||
var days = Math.floor(totalSeconds / (3600 * 24));
|
||||
var hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
|
||||
var minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||
var seconds = Math.floor(totalSeconds % 60);
|
||||
var dayDisplay = days > 0 ? days + (days === 1 ? " day, " : " days, ") : "";
|
||||
var hourDisplay = hours > 0 ? hours + (hours === 1 ? " hour, " : " hours, ") : "";
|
||||
var minuteDisplay = minutes > 0 ? minutes + (minutes === 1 ? " minute, " : " minutes, ") : "";
|
||||
var secondDisplay = seconds > 0 ? seconds + (seconds === 1 ? " second" : " seconds") : "";
|
||||
const days = Math.floor(totalSeconds / (3600 * 24));
|
||||
const hours = Math.floor((totalSeconds % (3600 * 24)) / 3600);
|
||||
const minutes = Math.floor((totalSeconds % 3600) / 60);
|
||||
const seconds = Math.floor(totalSeconds % 60);
|
||||
const dayDisplay = days > 0 ? days + (days === 1 ? " day, " : " days, ") : "";
|
||||
const hourDisplay = hours > 0 ? hours + (hours === 1 ? " hour, " : " hours, ") : "";
|
||||
const minuteDisplay = minutes > 0 ? minutes + (minutes === 1 ? " minute, " : " minutes, ") : "";
|
||||
const secondDisplay = seconds > 0 ? seconds + (seconds === 1 ? " second" : " seconds") : "";
|
||||
return (dayDisplay + hourDisplay + minuteDisplay + secondDisplay).replace(/,\s*$/, "");
|
||||
}
|
||||
export function formatSecondsToMS(s) {
|
||||
const mins = Math.floor(s / 60);
|
||||
const secs = s % 60;
|
||||
return `${mins}:${secs < 10 ? "0" : ""}${secs}`;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user