🐛 Fix bug where incorrect end time is shown

This commit is contained in:
Luke Vella 2023-06-09 10:49:27 +01:00
parent b2dfee4042
commit 712616e0f6

View file

@ -101,13 +101,16 @@ const parseTimeSlotOption = (
timeZone: string | null, timeZone: string | null,
targetTimeZone: string, targetTimeZone: string,
): ParsedTimeSlotOption => { ): ParsedTimeSlotOption => {
const start = dayjs(option.start).utc(); const adjustTimeZone = (date: Date | dayjs.Dayjs) => {
const startDate = return timeZone && targetTimeZone
timeZone && targetTimeZone ? dayjs(date).utc().tz(timeZone, true).tz(targetTimeZone)
? start.tz(timeZone, true).tz(targetTimeZone) : dayjs(date).utc();
: start; };
const startDate = adjustTimeZone(option.start);
const endDate = startDate.add(option.duration, "minute"); const endDate = adjustTimeZone(
dayjs(option.start).add(option.duration, "minute"),
);
return { return {
type: "timeSlot", type: "timeSlot",