fix: missing date overrides in negative tz (#15251)

* fix check for past date overrides

* add test

---------

Co-authored-by: CarinaWolli <[email protected]>
This commit is contained in:
Carina WollendorferandCarinaWolli authored and GitHub committed 2024-05-29 23:35:43 +00:00
1 parent 817a3decb7
commit d4f3726875
3 files changed
+29 -2

No files matched your search

@@ -194,6 +194,7 @@ export function AvailabilityEditSheetForm(props: Props & { data: Data; isPending
id="timezone"
isDisabled={!hasEditPermission || !data.hasDefaultSchedule}
value={watchTimezone ?? "Europe/London"}
data-testid="timezone-select"
onChange={(event) => {
if (event) form.setValue("timeZone", event.value, { shouldDirty: true });
}}
@@ -37,8 +37,11 @@ export function transformAvailabilityForClient(schedule: ScheduleWithAvailabilit
export function transformDateOverridesForClient(schedule: ScheduleWithAvailabilities, timeZone: string) {
return schedule.availability.reduce((acc, override) => {
// only iff future date override
if (!override.date || dayjs.tz(override.date, timeZone).isBefore(dayjs(), "day")) {
// only if future date override
const currentUtcOffset = dayjs().tz(timeZone).utcOffset();
const currentTimeInTz = dayjs().utc().add(currentUtcOffset, "minute");
if (!override.date || dayjs(override.date).isBefore(currentTimeInTz, "day")) {
return acc;
}
const newValue = {