mirror of
https://github.com/nicotsx/ironmount.git
synced 2025-12-10 12:10:51 +01:00
18 lines
388 B
TypeScript
18 lines
388 B
TypeScript
export const getCronExpression = (frequency: string, dailyTime?: string, weeklyDay?: string): string => {
|
|
if (frequency === "hourly") {
|
|
return "0 * * * *";
|
|
}
|
|
|
|
if (!dailyTime) {
|
|
dailyTime = "02:00";
|
|
}
|
|
|
|
const [hours, minutes] = dailyTime.split(":");
|
|
|
|
if (frequency === "daily") {
|
|
return `${minutes} ${hours} * * *`;
|
|
}
|
|
|
|
return `${minutes} ${hours} * * ${weeklyDay ?? "0"}`;
|
|
};
|