1 import { getPropertyTzid } from '@proton/shared/lib/calendar/vcalHelper';
2 import { addDays } from '@proton/shared/lib/date-fns-utc';
3 import { toUTCDate } from '@proton/shared/lib/date/timezone';
4 import type { VcalDateOrDateTimeProperty } from '@proton/shared/lib/interfaces/calendar/VcalModel';
6 import { getDateTimeState } from './time';
8 const propertiesToDateTimeModel = (
9 dtstart: VcalDateOrDateTimeProperty,
10 dtend: VcalDateOrDateTimeProperty,
14 const localStart = toUTCDate(dtstart.value);
15 const localEnd = toUTCDate(dtend.value);
18 // All day events date ranges are stored non-inclusively, so remove a full day from the end date
19 const modifiedEnd = addDays(localEnd, -1);
22 start: getDateTimeState(localStart, tzid),
23 end: getDateTimeState(modifiedEnd, tzid),
27 const tzStart = getPropertyTzid(dtstart) || tzid;
28 const tzEnd = getPropertyTzid(dtend) || tzid;
31 start: getDateTimeState(localStart, tzStart),
32 end: getDateTimeState(localEnd, tzEnd),
36 export default propertiesToDateTimeModel;