1 import { convertZonedDateTimeToUTC, toUTCDate } from '@proton/shared/lib/date/timezone';
2 import type { DateTimeModel } from '@proton/shared/lib/interfaces/calendar';
4 export const getDateTimeState = (utcDate: Date, tzid: string): DateTimeModel => {
6 // These should be local dates since the mini calendar and time input uses that.
7 date: new Date(utcDate.getUTCFullYear(), utcDate.getUTCMonth(), utcDate.getUTCDate(), 0, 0),
8 // Assuming there is no timezone that has a DST shift at this date
9 time: new Date(2000, 0, 1, utcDate.getUTCHours(), utcDate.getUTCMinutes()),
14 export const getDateTime = ({ date, time }: DateTimeModel) => {
15 return new Date(date.getFullYear(), date.getMonth(), date.getDate(), time.getHours(), time.getMinutes());
18 export const getTimeInUtc = ({ date, time, tzid }: DateTimeModel, isAllDay: boolean) => {
21 year: date.getFullYear(),
22 month: date.getMonth() + 1,
27 convertZonedDateTimeToUTC(
29 year: date.getFullYear(),
30 month: date.getMonth() + 1,
32 hours: time.getHours(),
33 minutes: time.getMinutes(),