/** * RRULE building and parsing helpers. */ export type RepeatType = "Tag" | "Woche" | "Monat" | "Jahr"; const REPEAT_TYPE_TO_FREQ: Record = { Tag: "DAILY", Woche: "WEEKLY", Monat: "MONTHLY", Jahr: "YEARLY", }; /** * Build an RRULE string from repeat count and type. * * @param repeatType - The type of repetition (Tag, Woche, Monat, Jahr) * @param interval - The interval between repetitions (default: 1) * @returns RRULE string like "FREQ=WEEKLY;INTERVAL=2" */ export function buildRRule(repeatType: RepeatType, interval: number = 1): string { const freq = REPEAT_TYPE_TO_FREQ[repeatType]; if (interval <= 1) { return `FREQ=${freq}`; } return `FREQ=${freq};INTERVAL=${interval}`; }