fix: Stores the DateRange in UTC instead of user machine that caused the bug (#26900)

* fix init

* remove comment

* fix to v2

* type fix

* edge case

* test fix to suit the date storage method

* fix for atoms

* backward compatibility

* fix test mock

* test fix?

* testing a theory

* address cubic
This commit is contained in:
Syed Ali Shahbaz authored and GitHub committed 2026-01-19 10:41:53 +02:00
1 parent 9f0d035a3b
commit c1d0a6bb1b
7 files changed
+647 -89

No files matched your search

@@ -1,16 +1,12 @@
import { useAutoAnimate } from "@formkit/auto-animate/react";
import * as RadioGroup from "@radix-ui/react-radio-group";
import type { Key } from "react";
import React, { useEffect, useState } from "react";
import type { UseFormRegisterReturn, UseFormReturn } from "react-hook-form";
import { Controller, useFormContext } from "react-hook-form";
import type { SingleValue } from "react-select";
import useLockedFieldsManager from "@calcom/features/ee/managed-event-types/hooks/useLockedFieldsManager";
import { LearnMoreLink } from "@calcom/web/modules/event-types/components/LearnMoreLink";
import { getDefinedBufferTimes } from "@calcom/features/eventtypes/lib/getDefinedBufferTimes";
import type { FormValues, EventTypeSetupProps, InputClassNames } from "@calcom/features/eventtypes/lib/types";
import type { SelectClassNames, SettingsToggleClassNames } from "@calcom/features/eventtypes/lib/types";
import type {
EventTypeSetupProps,
FormValues,
InputClassNames,
SelectClassNames,
SettingsToggleClassNames,
} from "@calcom/features/eventtypes/lib/types";
import CheckboxField from "@calcom/features/form/components/CheckboxField";
import { ROLLING_WINDOW_PERIOD_MAX_DAYS_TO_CHECK } from "@calcom/lib/constants";
import type { DurationType } from "@calcom/lib/convertToNewDurationType";
@@ -23,15 +19,23 @@ import { PeriodType } from "@calcom/prisma/enums";
import classNames from "@calcom/ui/classNames";
import { Button } from "@calcom/ui/components/button";
import {
InputField,
DateRangePicker,
InputField,
Label,
TextField,
Select,
SettingsToggle,
TextField,
} from "@calcom/ui/components/form";
import { Icon } from "@calcom/ui/components/icon";
import { Tooltip } from "@calcom/ui/components/tooltip";
import { LearnMoreLink } from "@calcom/web/modules/event-types/components/LearnMoreLink";
import { useAutoAnimate } from "@formkit/auto-animate/react";
import * as RadioGroup from "@radix-ui/react-radio-group";
import type { Key } from "react";
import React, { useEffect, useState } from "react";
import type { UseFormRegisterReturn, UseFormReturn } from "react-hook-form";
import { Controller, useFormContext } from "react-hook-form";
import type { SingleValue } from "react-select";
import MaxActiveBookingsPerBookerController from "./MaxActiveBookingsPerBookerController";
@@ -158,9 +162,14 @@ function RangeLimitRadioItem({
}}
disabled={isDisabled}
onDatesChange={({ startDate, endDate }) => {
const toUTCMidnight = (date: Date | undefined): Date | undefined => {
if (!date) return undefined;
return new Date(Date.UTC(date.getFullYear(), date.getMonth(), date.getDate()));
};
onChange({
startDate,
endDate,
startDate: toUTCMidnight(startDate),
endDate: toUTCMidnight(endDate),
});
}}
className={customClassNames?.datePicker}
@@ -965,9 +974,8 @@ export const IntervalLimitsManager = <K extends "durationLimits" | "bookingLimit
setValue(
propertyName,
// TODO: Remove @ts-ignore, type error no longer exists in later TS versions.
// TODO: Remove @ts-expect-error, type error no longer exists in later TS versions.
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
{
...watchIntervalLimits,
[rest.value]: defaultLimit,