Merge branch 'IDTEAM-1.26.0' into 'main'
[ProtonMail-WebClient.git] / packages / shared / lib / calendar / recurrence / rruleUntil.ts
blob0ffe1873e7a6e9ffd9aebe862da34acc1638070d
1 import type { VcalDateOrDateTimeProperty, VcalRruleProperty } from '../../interfaces/calendar/VcalModel';
2 import { getUntilProperty } from '../vcalConverter';
3 import { getIsPropertyAllDay, getPropertyTzid } from '../vcalHelper';
5 export const withRruleUntil = (rrule: VcalRruleProperty, dtstart: VcalDateOrDateTimeProperty): VcalRruleProperty => {
6     const until = rrule.value?.until;
7     if (!until) {
8         return rrule;
9     }
10     return {
11         ...rrule,
12         value: {
13             ...rrule.value,
14             until: getUntilProperty(until, getIsPropertyAllDay(dtstart), getPropertyTzid(dtstart)),
15         },
16     };