change to ES2022

This commit is contained in:
Darius
2025-11-18 21:46:48 +01:00
parent 9b02c09677
commit 314ef5c2ff
6 changed files with 26 additions and 81 deletions

14
dist/timehelper.js vendored
View File

@@ -1,9 +1,6 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TimeSpan = void 0;
exports.calculateSecondsBetween = calculateSecondsBetween;
exports.secondsToReadable = secondsToReadable;
class TimeSpan {
export class TimeSpan {
start;
end;
constructor(timeSpanStr) {
const [startStr, endStr] = timeSpanStr.split("-");
this.start = this.parseTime(startStr);
@@ -28,15 +25,14 @@ class TimeSpan {
}
}
}
exports.TimeSpan = TimeSpan;
function calculateSecondsBetween(start, end) {
export function calculateSecondsBetween(start, end) {
const seconds = Math.max(60, (end - start) / 1000);
return {
seconds,
toReadable: (roundToMinutes) => secondsToReadable(seconds, roundToMinutes),
};
}
function secondsToReadable(secs, roundToMinutes = false) {
export function secondsToReadable(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);