@thisisagile/easy
Version:
Straightforward library for building domain-driven microservice architectures
26 lines (24 loc) • 737 B
JavaScript
import {
toList
} from "./chunk-A7C3XND3.mjs";
import {
ifTrue
} from "./chunk-JSON7A4X.mjs";
// src/utils/Seconds.ts
var seconds = {
toDuration: (s) => {
const seconds2 = s % 60;
const minutes = Math.floor(s / 60) % 60;
const hours = Math.floor(s / 3600) % 24;
const days = Math.floor(s / 86400);
return { days, hours, minutes, seconds: seconds2 };
},
toText: (s) => {
const { days, hours, minutes, seconds: secs } = seconds.toDuration(s);
return toList(ifTrue(days, `${days}d`), ifTrue(hours, `${hours}h`), ifTrue(minutes, `${minutes}m`), ifTrue(days + hours + minutes === 0, `${secs}s`)).mapDefined((s2) => s2).join(" ");
}
};
export {
seconds
};
//# sourceMappingURL=chunk-JQQGQCYH.mjs.map