feat: backup progress

This commit is contained in:
Nicolas Meienberger
2025-11-09 12:11:00 +01:00
parent 4389029ba5
commit 5ff48f4d5d
13 changed files with 256 additions and 21 deletions

View File

@@ -1,3 +1,5 @@
import { intervalToDuration } from "date-fns";
export const getCronExpression = (frequency: string, dailyTime?: string, weeklyDay?: string): string => {
if (frequency === "hourly") {
return "0 * * * *";
@@ -15,3 +17,15 @@ export const getCronExpression = (frequency: string, dailyTime?: string, weeklyD
return `${minutes} ${hours} * * ${weeklyDay ?? "0"}`;
};
export const formatDuration = (seconds: number) => {
const duration = intervalToDuration({ start: 0, end: seconds * 1000 });
const parts: string[] = [];
if (duration.days) parts.push(`${duration.days}d`);
if (duration.hours) parts.push(`${duration.hours}h`);
if (duration.minutes) parts.push(`${duration.minutes}m`);
if (duration.seconds || parts.length === 0) parts.push(`${duration.seconds || 0}s`);
return parts.join(" ");
};