Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
selectTimeSlot (slot) {
// Note - For cross browser, we must use specific date string format below
// Chrome/FF pass with "2020-05-08 09:00" but Safari fails.
// Safari needs format from spec, "2020-05-08T09:00-07:00"
// (safari also needs timezone offset)
const selectedSlot: AppointmentSlot = {
// start_time: new Date(`${this.selectedDate}T${slot.start_time}${timezoneOffset()}`).toISOString(),
// end_time: new Date(`${this.selectedDate}T${slot.end_time}${timezoneOffset()}`).toISOString()
start_time: zonedTimeToUtc(`${this.selectedDate}T${slot.start_time}`, this.currentOfficeTimezone).toISOString(),
end_time: zonedTimeToUtc(`${this.selectedDate}T${slot.end_time}`, this.currentOfficeTimezone).toISOString()
}
this.setCurrentAppointmentSlot(selectedSlot)
this.stepNext()
}
}
const distanceInWordsToNow = date =>
formatDistanceToNow(zonedTimeToUtc(date, 'Etc/UTC'));
const localTimeToUtc: DateFn = (date: Date | string | number): Date => {
return zonedTimeToUtc(date, config.timezone.name);
};
function getEstString(date: Date) {
const dateUTC = zonedTimeToUtc(
startOfDay(date),
Intl.DateTimeFormat().resolvedOptions().timeZone,
);
const dateEST = utcToZonedTime(dateUTC, 'EST');
return format(dateEST, 'yyyyMMdd');
}