diff --git a/apps/web/components/availability/Schedule.tsx b/apps/web/components/availability/Schedule.tsx index b910d72cfd..22a60acb19 100644 --- a/apps/web/components/availability/Schedule.tsx +++ b/apps/web/components/availability/Schedule.tsx @@ -1,13 +1,11 @@ import { PlusIcon, TrashIcon } from "@heroicons/react/outline"; import { DuplicateIcon } from "@heroicons/react/solid"; import classNames from "classnames"; -import dayjs, { Dayjs, ConfigType } from "dayjs"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; import React, { useCallback, useEffect, useMemo, useState } from "react"; import { Controller, useFieldArray, useFormContext } from "react-hook-form"; import { GroupBase, Props } from "react-select"; +import dayjs, { Dayjs, ConfigType } from "@calcom/dayjs"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import Button from "@calcom/ui/Button"; import Dropdown, { DropdownMenuTrigger, DropdownMenuContent } from "@calcom/ui/Dropdown"; @@ -19,9 +17,6 @@ import { TimeRange } from "@lib/types/schedule"; import Select from "@components/ui/form/Select"; -dayjs.extend(utc); -dayjs.extend(timezone); - /** Begin Time Increments For Select */ const increment = 15; diff --git a/apps/web/components/booking/AvailableTimes.tsx b/apps/web/components/booking/AvailableTimes.tsx index 3a78be01a9..01086584f7 100644 --- a/apps/web/components/booking/AvailableTimes.tsx +++ b/apps/web/components/booking/AvailableTimes.tsx @@ -1,9 +1,9 @@ import { SchedulingType } from "@prisma/client"; -import dayjs, { Dayjs } from "dayjs"; import Link from "next/link"; import { useRouter } from "next/router"; import { FC, useEffect, useState } from "react"; +import dayjs, { Dayjs } from "@calcom/dayjs"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { nameOfDay } from "@calcom/lib/weekday"; import { SkeletonContainer, SkeletonText } from "@calcom/ui"; diff --git a/apps/web/components/booking/BookingListItem.tsx b/apps/web/components/booking/BookingListItem.tsx index 429f3ea16d..bfbb9d5a6a 100644 --- a/apps/web/components/booking/BookingListItem.tsx +++ b/apps/web/components/booking/BookingListItem.tsx @@ -9,11 +9,11 @@ import { } from "@heroicons/react/outline"; import { RefreshIcon } from "@heroicons/react/solid"; import { BookingStatus } from "@prisma/client"; -import dayjs from "dayjs"; import { useRouter } from "next/router"; import { useState } from "react"; import { useMutation } from "react-query"; +import dayjs from "@calcom/dayjs"; import { parseRecurringEvent } from "@calcom/lib"; import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; diff --git a/apps/web/components/booking/DatePicker.tsx b/apps/web/components/booking/DatePicker.tsx index dff8255e75..2db969e538 100644 --- a/apps/web/components/booking/DatePicker.tsx +++ b/apps/web/components/booking/DatePicker.tsx @@ -1,12 +1,9 @@ import { ChevronLeftIcon, ChevronRightIcon } from "@heroicons/react/solid"; import { PeriodType } from "@prisma/client"; -import dayjs, { Dayjs } from "dayjs"; -import dayjsBusinessTime from "dayjs-business-days2"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; import { memoize } from "lodash"; import { useEffect, useRef, useState } from "react"; +import dayjs, { Dayjs } from "@calcom/dayjs"; import { useEmbedStyles } from "@calcom/embed-core/embed-iframe"; import { useLocale } from "@calcom/lib/hooks/useLocale"; @@ -20,10 +17,6 @@ import { WorkingHours } from "@lib/types/schedule"; import Loader from "@components/Loader"; -dayjs.extend(dayjsBusinessTime); -dayjs.extend(utc); -dayjs.extend(timezone); - type DatePickerProps = { weekStart: string; onDatePicked: (pickedDate: Dayjs) => void; diff --git a/apps/web/components/booking/pages/AvailabilityPage.tsx b/apps/web/components/booking/pages/AvailabilityPage.tsx index 957e10a7fd..689088e616 100644 --- a/apps/web/components/booking/pages/AvailabilityPage.tsx +++ b/apps/web/components/booking/pages/AvailabilityPage.tsx @@ -15,10 +15,6 @@ import { import { EventType } from "@prisma/client"; import * as Collapsible from "@radix-ui/react-collapsible"; import { useContracts } from "contexts/contractsContext"; -import dayjs, { Dayjs } from "dayjs"; -import customParseFormat from "dayjs/plugin/customParseFormat"; -import timeZone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; import { TFunction } from "next-i18next"; import { useRouter } from "next/router"; import { useEffect, useMemo, useState } from "react"; @@ -26,6 +22,7 @@ import { FormattedNumber, IntlProvider } from "react-intl"; import { z } from "zod"; import { AppStoreLocationType, LocationObject, LocationType } from "@calcom/app-store/locations"; +import dayjs, { Dayjs } from "@calcom/dayjs"; import { useEmbedNonStylesConfig, useEmbedStyles, @@ -60,10 +57,6 @@ import type { AvailabilityPageProps } from "../../../pages/[user]/[type]"; import type { DynamicAvailabilityPageProps } from "../../../pages/d/[link]/[slug]"; import type { AvailabilityTeamPageProps } from "../../../pages/team/[slug]/[type]"; -dayjs.extend(utc); -dayjs.extend(timeZone); -dayjs.extend(customParseFormat); - type Props = AvailabilityTeamPageProps | AvailabilityPageProps | DynamicAvailabilityPageProps; export const locationKeyToString = (location: LocationObject, t: TFunction) => { diff --git a/apps/web/components/booking/pages/BookingPage.tsx b/apps/web/components/booking/pages/BookingPage.tsx index 1f493e26c5..8c793e3426 100644 --- a/apps/web/components/booking/pages/BookingPage.tsx +++ b/apps/web/components/booking/pages/BookingPage.tsx @@ -11,7 +11,6 @@ import { import { zodResolver } from "@hookform/resolvers/zod"; import { EventTypeCustomInputType } from "@prisma/client"; import { useContracts } from "contexts/contractsContext"; -import dayjs from "dayjs"; import { useSession } from "next-auth/react"; import dynamic from "next/dynamic"; import Head from "next/head"; @@ -24,6 +23,7 @@ import { useMutation } from "react-query"; import { v4 as uuidv4 } from "uuid"; import { z } from "zod"; +import dayjs from "@calcom/dayjs"; import { useEmbedNonStylesConfig, useIsBackgroundTransparent, diff --git a/apps/web/ee/components/TrialBanner.tsx b/apps/web/ee/components/TrialBanner.tsx index d5b4172a5d..b80cb19dd3 100644 --- a/apps/web/ee/components/TrialBanner.tsx +++ b/apps/web/ee/components/TrialBanner.tsx @@ -1,5 +1,4 @@ -import dayjs from "dayjs"; - +import dayjs from "@calcom/dayjs"; import Button from "@calcom/ui/Button"; import { TRIAL_LIMIT_DAYS } from "@lib/config/constants"; diff --git a/apps/web/ee/components/apiKeys/ApiKeyDialogForm.tsx b/apps/web/ee/components/apiKeys/ApiKeyDialogForm.tsx index 783036f464..4cd03bc915 100644 --- a/apps/web/ee/components/apiKeys/ApiKeyDialogForm.tsx +++ b/apps/web/ee/components/apiKeys/ApiKeyDialogForm.tsx @@ -1,8 +1,8 @@ import { ClipboardCopyIcon } from "@heroicons/react/solid"; -import dayjs from "dayjs"; import { useState } from "react"; import { Controller, useForm } from "react-hook-form"; +import dayjs from "@calcom/dayjs"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import showToast from "@calcom/lib/notification"; import Button from "@calcom/ui/Button"; diff --git a/apps/web/ee/components/apiKeys/ApiKeyListItem.tsx b/apps/web/ee/components/apiKeys/ApiKeyListItem.tsx index 4b36bad2ff..f58338a084 100644 --- a/apps/web/ee/components/apiKeys/ApiKeyListItem.tsx +++ b/apps/web/ee/components/apiKeys/ApiKeyListItem.tsx @@ -1,8 +1,7 @@ import { PencilAltIcon, TrashIcon } from "@heroicons/react/outline"; import { ExclamationIcon } from "@heroicons/react/solid"; -import dayjs from "dayjs"; -import relativeTime from "dayjs/plugin/relativeTime"; +import dayjs from "@calcom/dayjs"; import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import Button from "@calcom/ui/Button"; @@ -15,8 +14,6 @@ import { ListItem } from "@components/List"; import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; import Badge from "@components/ui/Badge"; -dayjs.extend(relativeTime); - export type TApiKeys = inferQueryOutput<"viewer.apiKeys.list">[number]; export default function ApiKeyListItem(props: { apiKey: TApiKeys; onEditApiKey: () => void }) { diff --git a/apps/web/ee/components/stripe/PaymentPage.tsx b/apps/web/ee/components/stripe/PaymentPage.tsx index 285a82c52e..5636b434bc 100644 --- a/apps/web/ee/components/stripe/PaymentPage.tsx +++ b/apps/web/ee/components/stripe/PaymentPage.tsx @@ -1,14 +1,11 @@ import { CreditCardIcon } from "@heroicons/react/solid"; import { Elements } from "@stripe/react-stripe-js"; import classNames from "classnames"; -import dayjs from "dayjs"; -import timezone from "dayjs/plugin/timezone"; -import toArray from "dayjs/plugin/toArray"; -import utc from "dayjs/plugin/utc"; import Head from "next/head"; import { FC, useEffect, useState } from "react"; import { FormattedNumber, IntlProvider } from "react-intl"; +import dayjs from "@calcom/dayjs"; import { sdkActionManager, useIsEmbed } from "@calcom/embed-core/embed-iframe"; import getStripe from "@calcom/stripe/client"; import PaymentComponent from "@ee/components/stripe/Payment"; @@ -19,10 +16,6 @@ import useTheme from "@lib/hooks/useTheme"; import { LocationOptionsToString } from "@lib/locationOptions"; import { isBrowserLocale24h } from "@lib/timeFormat"; -dayjs.extend(utc); -dayjs.extend(toArray); -dayjs.extend(timezone); - const PaymentPage: FC = (props) => { const { t } = useLocale(); const [is24h, setIs24h] = useState(isBrowserLocale24h()); diff --git a/apps/web/ee/components/team/availability/TeamAvailabilityModal.tsx b/apps/web/ee/components/team/availability/TeamAvailabilityModal.tsx index 985c307e3e..8de7650a5c 100644 --- a/apps/web/ee/components/team/availability/TeamAvailabilityModal.tsx +++ b/apps/web/ee/components/team/availability/TeamAvailabilityModal.tsx @@ -1,7 +1,6 @@ -import dayjs from "dayjs"; -import utc from "dayjs/plugin/utc"; import React, { useState, useEffect } from "react"; +import dayjs from "@calcom/dayjs"; import { WEBAPP_URL } from "@calcom/lib/constants"; import LicenseRequired from "@ee/components/LicenseRequired"; @@ -14,8 +13,6 @@ import TimezoneSelect, { ITimezone } from "@components/ui/form/TimezoneSelect"; import TeamAvailabilityTimes from "./TeamAvailabilityTimes"; -dayjs.extend(utc); - interface Props { team?: inferQueryOutput<"viewer.teams.get">; member?: inferQueryOutput<"viewer.teams.get">["members"][number]; diff --git a/apps/web/ee/components/team/availability/TeamAvailabilityScreen.tsx b/apps/web/ee/components/team/availability/TeamAvailabilityScreen.tsx index e81319719a..51d5071dc3 100644 --- a/apps/web/ee/components/team/availability/TeamAvailabilityScreen.tsx +++ b/apps/web/ee/components/team/availability/TeamAvailabilityScreen.tsx @@ -1,8 +1,8 @@ -import dayjs from "dayjs"; import React, { useState, useEffect, CSSProperties } from "react"; import AutoSizer from "react-virtualized-auto-sizer"; import { FixedSizeList as List } from "react-window"; +import dayjs from "@calcom/dayjs"; import { CAL_URL } from "@calcom/lib/constants"; import { inferQueryOutput, trpc } from "@lib/trpc"; diff --git a/apps/web/ee/components/team/availability/TeamAvailabilityTimes.tsx b/apps/web/ee/components/team/availability/TeamAvailabilityTimes.tsx index 18f4d0ae93..f89aff6718 100644 --- a/apps/web/ee/components/team/availability/TeamAvailabilityTimes.tsx +++ b/apps/web/ee/components/team/availability/TeamAvailabilityTimes.tsx @@ -1,9 +1,9 @@ import classNames from "classnames"; -import dayjs, { Dayjs } from "dayjs"; -import utc from "dayjs/plugin/utc"; import React from "react"; import { ITimezone } from "react-timezone-select"; +import { Dayjs } from "@calcom/dayjs"; + import getSlots from "@lib/slots"; import { trpc } from "@lib/trpc"; @@ -19,8 +19,6 @@ interface Props { className?: string; } -dayjs.extend(utc); - export default function TeamAvailabilityTimes(props: Props) { const { data, isLoading } = trpc.useQuery( [ diff --git a/apps/web/lib/clock.ts b/apps/web/lib/clock.ts index cc3d0b8248..12e7955988 100644 --- a/apps/web/lib/clock.ts +++ b/apps/web/lib/clock.ts @@ -1,15 +1,9 @@ // handles logic related to user clock display using 24h display / timeZone options. -import dayjs from "dayjs"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; - +import dayjs from "@calcom/dayjs"; import { localStorage } from "@calcom/lib/webstorage"; import { isBrowserLocale24h } from "./timeFormat"; -dayjs.extend(utc); -dayjs.extend(timezone); - interface TimeOptions { is24hClock: boolean; inviteeTimeZone: string; diff --git a/apps/web/lib/getting-started.tsx b/apps/web/lib/getting-started.tsx index 601e8b9549..8da6333da6 100644 --- a/apps/web/lib/getting-started.tsx +++ b/apps/web/lib/getting-started.tsx @@ -1,5 +1,6 @@ import { User } from "@prisma/client"; -import dayjs from "dayjs"; + +import dayjs from "@calcom/dayjs"; export const ONBOARDING_INTRODUCED_AT = dayjs("September 1 2021").toISOString(); diff --git a/apps/web/lib/hooks/useSlots.ts b/apps/web/lib/hooks/useSlots.ts index 9119ba1a39..c319a04907 100644 --- a/apps/web/lib/hooks/useSlots.ts +++ b/apps/web/lib/hooks/useSlots.ts @@ -1,18 +1,13 @@ import { SchedulingType } from "@prisma/client"; -import dayjs, { Dayjs } from "dayjs"; -import isBetween from "dayjs/plugin/isBetween"; -import utc from "dayjs/plugin/utc"; import { stringify } from "querystring"; import { useEffect, useState } from "react"; import type { CurrentSeats } from "@calcom/core/getUserAvailability"; +import dayjs, { Dayjs } from "@calcom/dayjs"; import getSlots from "@lib/slots"; import type { TimeRange, WorkingHours } from "@lib/types/schedule"; -dayjs.extend(isBetween); -dayjs.extend(utc); - type AvailabilityUserResponse = { busy: TimeRange[]; timeZone: string; diff --git a/apps/web/lib/isOutOfBounds.tsx b/apps/web/lib/isOutOfBounds.tsx index 85c65cf33e..1a115f737d 100644 --- a/apps/web/lib/isOutOfBounds.tsx +++ b/apps/web/lib/isOutOfBounds.tsx @@ -1,8 +1,6 @@ import { EventType, PeriodType } from "@prisma/client"; -import dayjs from "dayjs"; -import dayjsBusinessTime from "dayjs-business-days2"; -dayjs.extend(dayjsBusinessTime); +import dayjs from "@calcom/dayjs"; function isOutOfBounds( time: dayjs.ConfigType, diff --git a/apps/web/lib/parseDate.ts b/apps/web/lib/parseDate.ts index 2769ca1891..9fca8e3006 100644 --- a/apps/web/lib/parseDate.ts +++ b/apps/web/lib/parseDate.ts @@ -1,7 +1,7 @@ -import dayjs, { Dayjs } from "dayjs"; import { I18n } from "next-i18next"; import { RRule } from "rrule"; +import dayjs, { Dayjs } from "@calcom/dayjs"; import { RecurringEvent } from "@calcom/types/Calendar"; import { detectBrowserTimeFormat } from "@lib/timeFormat"; diff --git a/apps/web/lib/parseZone.ts b/apps/web/lib/parseZone.ts index 10a9374625..9d9454dfcd 100644 --- a/apps/web/lib/parseZone.ts +++ b/apps/web/lib/parseZone.ts @@ -1,4 +1,4 @@ -import dayjs from "dayjs"; +import dayjs from "@calcom/dayjs"; const ISO8601_OFFSET_FORMAT = /^(.*)([+-])(\d{2}):(\d{2})|(Z)$/; diff --git a/apps/web/lib/slots.ts b/apps/web/lib/slots.ts index 758b2823da..b76eb487c8 100644 --- a/apps/web/lib/slots.ts +++ b/apps/web/lib/slots.ts @@ -1,15 +1,8 @@ -import dayjs, { Dayjs } from "dayjs"; -import isBetween from "dayjs/plugin/isBetween"; -import isToday from "dayjs/plugin/isToday"; -import utc from "dayjs/plugin/utc"; +import dayjs, { Dayjs } from "@calcom/dayjs"; import { getWorkingHours } from "./availability"; import { WorkingHours } from "./types/schedule"; -dayjs.extend(isToday); -dayjs.extend(utc); -dayjs.extend(isBetween); - export type GetSlots = { inviteeDate: Dayjs; frequency: number; diff --git a/apps/web/next.config.js b/apps/web/next.config.js index 0dc69b0e4f..d4c5df87a8 100644 --- a/apps/web/next.config.js +++ b/apps/web/next.config.js @@ -3,6 +3,7 @@ require("dotenv").config({ path: "../../.env" }); const withTM = require("next-transpile-modules")([ "@calcom/app-store", "@calcom/core", + "@calcom/dayjs", "@calcom/ee", "@calcom/lib", "@calcom/prisma", diff --git a/apps/web/package.json b/apps/web/package.json index 9be91d3357..1dd6391f1f 100644 --- a/apps/web/package.json +++ b/apps/web/package.json @@ -30,6 +30,7 @@ "@calcom/app-store": "*", "@calcom/app-store-cli": "*", "@calcom/core": "*", + "@calcom/dayjs": "*", "@calcom/ee": "*", "@calcom/embed-core": "*", "@calcom/lib": "*", @@ -66,8 +67,6 @@ "async": "^3.2.1", "bcryptjs": "^2.4.3", "classnames": "^2.3.1", - "dayjs": "^1.11.2", - "dayjs-business-days2": "^1.1.0", "googleapis": "^84.0.0", "gray-matter": "^4.0.3", "handlebars": "^4.7.7", diff --git a/apps/web/pages/[user]/[type].tsx b/apps/web/pages/[user]/[type].tsx index ed25ac3f13..03552f3100 100644 --- a/apps/web/pages/[user]/[type].tsx +++ b/apps/web/pages/[user]/[type].tsx @@ -1,12 +1,11 @@ import { UserPlan } from "@prisma/client"; -import dayjs from "dayjs"; import { GetStaticPropsContext, GetStaticPaths } from "next"; -import { useRouter } from "next/router"; import { useEffect } from "react"; import { JSONObject } from "superjson/dist/types"; import { z } from "zod"; import { locationHiddenFilter, LocationObject } from "@calcom/app-store/locations"; +import dayjs from "@calcom/dayjs"; import { useIsEmbed } from "@calcom/embed-core/embed-iframe"; import { WEBAPP_URL } from "@calcom/lib/constants"; import { getDefaultEvent, getGroupName, getUsernameList } from "@calcom/lib/defaultEvents"; diff --git a/apps/web/pages/[user]/book.tsx b/apps/web/pages/[user]/book.tsx index ba389252ff..ad9c1894dc 100644 --- a/apps/web/pages/[user]/book.tsx +++ b/apps/web/pages/[user]/book.tsx @@ -1,6 +1,3 @@ -import dayjs from "dayjs"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; import { GetServerSidePropsContext } from "next"; import { JSONObject } from "superjson/dist/types"; @@ -24,9 +21,6 @@ import BookingPage from "@components/booking/pages/BookingPage"; import { ssrInit } from "@server/lib/ssr"; -dayjs.extend(utc); -dayjs.extend(timezone); - export type BookPageProps = inferSSRProps; export default function Book(props: BookPageProps) { diff --git a/apps/web/pages/api/auth/forgot-password.ts b/apps/web/pages/api/auth/forgot-password.ts index 6da67f7dd2..37a4a92532 100644 --- a/apps/web/pages/api/auth/forgot-password.ts +++ b/apps/web/pages/api/auth/forgot-password.ts @@ -1,11 +1,10 @@ import { ResetPasswordRequest } from "@prisma/client"; -import dayjs from "dayjs"; import { NextApiRequest, NextApiResponse } from "next"; +import dayjs from "@calcom/dayjs"; import { sendPasswordResetEmail } from "@calcom/emails"; import { PASSWORD_RESET_EXPIRY_HOURS } from "@calcom/emails/templates/forgot-password-email"; - -import prisma from "@lib/prisma"; +import prisma from "@calcom/prisma"; import { getTranslation } from "@server/lib/i18n"; diff --git a/apps/web/pages/api/book/event.ts b/apps/web/pages/api/book/event.ts index d6051935b5..09cd17ec9f 100644 --- a/apps/web/pages/api/book/event.ts +++ b/apps/web/pages/api/book/event.ts @@ -1,10 +1,5 @@ import { BookingStatus, Credential, Prisma, SchedulingType, WebhookTriggerEvents } from "@prisma/client"; import async from "async"; -import dayjs from "dayjs"; -import dayjsBusinessTime from "dayjs-business-days2"; -import isBetween from "dayjs/plugin/isBetween"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; import type { NextApiRequest } from "next"; import rrule from "rrule"; import short from "short-uuid"; @@ -12,6 +7,7 @@ import { v5 as uuidv5 } from "uuid"; import EventManager from "@calcom/core/EventManager"; import { getUserAvailability } from "@calcom/core/getUserAvailability"; +import dayjs from "@calcom/dayjs"; import { sendAttendeeRequestEmail, sendOrganizerRequestEmail, @@ -41,11 +37,6 @@ import { getTranslation } from "@server/lib/i18n"; import verifyAccount from "../../../web3/utils/verifyAccount"; -dayjs.extend(dayjsBusinessTime); -dayjs.extend(utc); -dayjs.extend(isBetween); -dayjs.extend(timezone); - const translator = short(); const log = logger.getChildLogger({ prefix: ["[api] book:user"] }); diff --git a/apps/web/pages/api/book/request-reschedule.ts b/apps/web/pages/api/book/request-reschedule.ts index 8a54528127..85a0e65527 100644 --- a/apps/web/pages/api/book/request-reschedule.ts +++ b/apps/web/pages/api/book/request-reschedule.ts @@ -7,7 +7,6 @@ import { User, WebhookTriggerEvents, } from "@prisma/client"; -import dayjs from "dayjs"; import type { NextApiRequest, NextApiResponse } from "next"; import { getSession } from "next-auth/react"; import type { TFunction } from "next-i18next"; @@ -17,6 +16,7 @@ import { getCalendar } from "@calcom/app-store/_utils/getCalendar"; import { CalendarEventBuilder } from "@calcom/core/builders/CalendarEvent/builder"; import { CalendarEventDirector } from "@calcom/core/builders/CalendarEvent/director"; import { deleteMeeting } from "@calcom/core/videoClient"; +import dayjs from "@calcom/dayjs"; import { sendRequestRescheduleEmail } from "@calcom/emails"; import { isPrismaObjOrUndefined } from "@calcom/lib"; import { getTranslation } from "@calcom/lib/server/i18n"; diff --git a/apps/web/pages/api/cancel.ts b/apps/web/pages/api/cancel.ts index 382369439c..ee60a7a244 100644 --- a/apps/web/pages/api/cancel.ts +++ b/apps/web/pages/api/cancel.ts @@ -1,11 +1,11 @@ import { BookingStatus, Credential, WebhookTriggerEvents } from "@prisma/client"; import async from "async"; -import dayjs from "dayjs"; import { NextApiRequest, NextApiResponse } from "next"; import { getCalendar } from "@calcom/app-store/_utils/getCalendar"; import { FAKE_DAILY_CREDENTIAL } from "@calcom/app-store/dailyvideo/lib/VideoApiAdapter"; import { deleteMeeting } from "@calcom/core/videoClient"; +import dayjs from "@calcom/dayjs"; import { sendCancelledEmails } from "@calcom/emails"; import { isPrismaObjOrUndefined, parseRecurringEvent } from "@calcom/lib"; import prisma, { bookingMinimalSelect } from "@calcom/prisma"; diff --git a/apps/web/pages/api/cron/bookingReminder.ts b/apps/web/pages/api/cron/bookingReminder.ts index b90ff94403..3a6a8f5c96 100644 --- a/apps/web/pages/api/cron/bookingReminder.ts +++ b/apps/web/pages/api/cron/bookingReminder.ts @@ -1,7 +1,7 @@ import { BookingStatus, ReminderType } from "@prisma/client"; -import dayjs from "dayjs"; import type { NextApiRequest, NextApiResponse } from "next"; +import dayjs from "@calcom/dayjs"; import { sendOrganizerRequestReminderEmail } from "@calcom/emails"; import { isPrismaObjOrUndefined, parseRecurringEvent } from "@calcom/lib"; import prisma, { bookingMinimalSelect } from "@calcom/prisma"; diff --git a/apps/web/pages/api/cron/downgradeUsers.ts b/apps/web/pages/api/cron/downgradeUsers.ts index 1a0fd303d9..045ac82b42 100644 --- a/apps/web/pages/api/cron/downgradeUsers.ts +++ b/apps/web/pages/api/cron/downgradeUsers.ts @@ -1,8 +1,9 @@ -import dayjs from "dayjs"; import type { NextApiRequest, NextApiResponse } from "next"; +import dayjs from "@calcom/dayjs"; +import prisma from "@calcom/prisma"; + import { TRIAL_LIMIT_DAYS } from "@lib/config/constants"; -import prisma from "@lib/prisma"; export default async function handler(req: NextApiRequest, res: NextApiResponse) { const apiKey = req.headers.authorization || req.query.apiKey; diff --git a/apps/web/pages/auth/forgot-password/[id].tsx b/apps/web/pages/auth/forgot-password/[id].tsx index f806ea3948..dd590d8fbf 100644 --- a/apps/web/pages/auth/forgot-password/[id].tsx +++ b/apps/web/pages/auth/forgot-password/[id].tsx @@ -1,13 +1,14 @@ import { ResetPasswordRequest } from "@prisma/client"; -import dayjs from "dayjs"; import debounce from "lodash/debounce"; import { GetServerSidePropsContext } from "next"; import { getCsrfToken } from "next-auth/react"; import Link from "next/link"; import React, { useMemo } from "react"; +import dayjs from "@calcom/dayjs"; +import prisma from "@calcom/prisma"; + import { useLocale } from "@lib/hooks/useLocale"; -import prisma from "@lib/prisma"; import { HeadSeo } from "@components/seo/head-seo"; diff --git a/apps/web/pages/availability/troubleshoot.tsx b/apps/web/pages/availability/troubleshoot.tsx index 78073f3d81..eafa6195cb 100644 --- a/apps/web/pages/availability/troubleshoot.tsx +++ b/apps/web/pages/availability/troubleshoot.tsx @@ -1,7 +1,6 @@ -import dayjs, { Dayjs } from "dayjs"; -import utc from "dayjs/plugin/utc"; import { useEffect, useState } from "react"; +import dayjs, { Dayjs } from "@calcom/dayjs"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { QueryCell } from "@lib/QueryCell"; @@ -10,8 +9,6 @@ import { inferQueryOutput, trpc } from "@lib/trpc"; import Loader from "@components/Loader"; import Shell from "@components/Shell"; -dayjs.extend(utc); - type User = inferQueryOutput<"viewer.me">; const AvailabilityView = ({ user }: { user: User }) => { diff --git a/apps/web/pages/cancel/[uid].tsx b/apps/web/pages/cancel/[uid].tsx index 6ba899dd22..7bd4d30d86 100644 --- a/apps/web/pages/cancel/[uid].tsx +++ b/apps/web/pages/cancel/[uid].tsx @@ -1,10 +1,10 @@ import { CalendarIcon, XIcon, RefreshIcon } from "@heroicons/react/solid"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@radix-ui/react-collapsible"; -import dayjs from "dayjs"; import { GetServerSidePropsContext } from "next"; import { useRouter } from "next/router"; import { useState } from "react"; +import dayjs from "@calcom/dayjs"; import classNames from "@calcom/lib/classNames"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { parseRecurringEvent } from "@calcom/lib/isRecurringEvent"; diff --git a/apps/web/pages/d/[link]/book.tsx b/apps/web/pages/d/[link]/book.tsx index d367882c65..db6a20125d 100644 --- a/apps/web/pages/d/[link]/book.tsx +++ b/apps/web/pages/d/[link]/book.tsx @@ -1,7 +1,3 @@ -import { Prisma } from "@prisma/client"; -import dayjs from "dayjs"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; import { GetServerSidePropsContext } from "next"; import { JSONObject } from "superjson/dist/types"; @@ -18,9 +14,6 @@ import BookingPage from "@components/booking/pages/BookingPage"; import { ssrInit } from "@server/lib/ssr"; -dayjs.extend(utc); -dayjs.extend(timezone); - export type HashLinkPageProps = inferSSRProps; export default function Book(props: HashLinkPageProps) { diff --git a/apps/web/pages/event-types/[type].tsx b/apps/web/pages/event-types/[type].tsx index ce165cdd76..d7d55deacd 100644 --- a/apps/web/pages/event-types/[type].tsx +++ b/apps/web/pages/event-types/[type].tsx @@ -12,16 +12,12 @@ import { TrashIcon, UserAddIcon, UsersIcon, - VideoCameraIcon, } from "@heroicons/react/solid"; import { zodResolver } from "@hookform/resolvers/zod"; import { EventTypeCustomInput, MembershipRole, PeriodType, Prisma, SchedulingType } from "@prisma/client"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@radix-ui/react-collapsible"; import * as RadioGroup from "@radix-ui/react-radio-group"; import classNames from "classnames"; -import dayjs from "dayjs"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; import { isValidPhoneNumber } from "libphonenumber-js"; import { GetServerSidePropsContext } from "next"; import { useRouter } from "next/router"; @@ -84,9 +80,6 @@ import { getTranslation } from "@server/lib/i18n"; import bloxyApi from "../../web3/dummyResps/bloxyApi"; -dayjs.extend(utc); -dayjs.extend(timezone); - interface Token { name?: string; address: string; diff --git a/apps/web/pages/getting-started.tsx b/apps/web/pages/getting-started.tsx index 43c579f8d1..7b6d71779a 100644 --- a/apps/web/pages/getting-started.tsx +++ b/apps/web/pages/getting-started.tsx @@ -2,10 +2,6 @@ import { ArrowRightIcon } from "@heroicons/react/outline"; import { zodResolver } from "@hookform/resolvers/zod"; import { Prisma } from "@prisma/client"; import classnames from "classnames"; -import dayjs from "dayjs"; -import localizedFormat from "dayjs/plugin/localizedFormat"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; import debounce from "lodash/debounce"; import omit from "lodash/omit"; import { NextPageContext } from "next"; @@ -18,6 +14,7 @@ import * as z from "zod"; import getApps from "@calcom/app-store/utils"; import { getCalendarCredentials, getConnectedCalendars } from "@calcom/core/CalendarManager"; +import dayjs from "@calcom/dayjs"; import { ResponseUsernameApi } from "@calcom/ee/lib/core/checkPremiumUsername"; import { Alert } from "@calcom/ui/Alert"; import Button from "@calcom/ui/Button"; @@ -40,10 +37,6 @@ import TimezoneSelect from "@components/ui/form/TimezoneSelect"; import getEventTypes from "../lib/queries/event-types/get-event-types"; -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.extend(localizedFormat); - type ScheduleFormValues = { schedule: ScheduleType; }; diff --git a/apps/web/pages/success.tsx b/apps/web/pages/success.tsx index ca5c3168ba..5784209c65 100644 --- a/apps/web/pages/success.tsx +++ b/apps/web/pages/success.tsx @@ -2,11 +2,6 @@ import { CheckIcon } from "@heroicons/react/outline"; import { ChevronLeftIcon, ClockIcon, XIcon } from "@heroicons/react/solid"; import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@radix-ui/react-collapsible"; import classNames from "classnames"; -import dayjs from "dayjs"; -import localizedFormat from "dayjs/plugin/localizedFormat"; -import timezone from "dayjs/plugin/timezone"; -import toArray from "dayjs/plugin/toArray"; -import utc from "dayjs/plugin/utc"; import { createEvent } from "ics"; import { GetServerSidePropsContext } from "next"; import { useSession } from "next-auth/react"; @@ -16,6 +11,7 @@ import { useEffect, useRef, useState } from "react"; import RRule from "rrule"; import { z } from "zod"; +import dayjs from "@calcom/dayjs"; import { sdkActionManager, useEmbedNonStylesConfig, @@ -47,11 +43,6 @@ import { HeadSeo } from "@components/seo/head-seo"; import { ssrInit } from "@server/lib/ssr"; -dayjs.extend(utc); -dayjs.extend(toArray); -dayjs.extend(timezone); -dayjs.extend(localizedFormat); - function redirectToExternalUrl(url: string) { window.parent.location.href = url; } diff --git a/apps/web/pages/video/meeting-ended/[uid].tsx b/apps/web/pages/video/meeting-ended/[uid].tsx index afad567d90..4b05a5bc1e 100644 --- a/apps/web/pages/video/meeting-ended/[uid].tsx +++ b/apps/web/pages/video/meeting-ended/[uid].tsx @@ -1,11 +1,11 @@ import { CalendarIcon, XIcon } from "@heroicons/react/outline"; import { ArrowRightIcon } from "@heroicons/react/solid"; -import dayjs from "dayjs"; import { NextPageContext } from "next"; import { getSession } from "next-auth/react"; import { useRouter } from "next/router"; import { useEffect } from "react"; +import dayjs from "@calcom/dayjs"; import prisma, { bookingMinimalSelect } from "@calcom/prisma"; import Button from "@calcom/ui/Button"; diff --git a/apps/web/pages/video/meeting-not-started/[uid].tsx b/apps/web/pages/video/meeting-not-started/[uid].tsx index abf24f8da5..4fcbb5a12c 100644 --- a/apps/web/pages/video/meeting-not-started/[uid].tsx +++ b/apps/web/pages/video/meeting-not-started/[uid].tsx @@ -1,11 +1,11 @@ import { CalendarIcon, XIcon } from "@heroicons/react/outline"; import { ArrowRightIcon } from "@heroicons/react/solid"; -import dayjs from "dayjs"; import { NextPageContext } from "next"; import { getSession } from "next-auth/react"; import { useRouter } from "next/router"; import { useEffect } from "react"; +import dayjs from "@calcom/dayjs"; import prisma, { bookingMinimalSelect } from "@calcom/prisma"; import type { inferSSRProps } from "@calcom/types/inferSSRProps"; import Button from "@calcom/ui/Button"; diff --git a/apps/web/playwright/fixtures/bookings.ts b/apps/web/playwright/fixtures/bookings.ts index ef4e2fa37e..444beab0e8 100644 --- a/apps/web/playwright/fixtures/bookings.ts +++ b/apps/web/playwright/fixtures/bookings.ts @@ -1,14 +1,11 @@ import type { Page } from "@playwright/test"; import type { Booking, Prisma } from "@prisma/client"; -import dayjs from "dayjs"; -import utc from "dayjs/plugin/utc"; import short from "short-uuid"; -import { v5 as uuidv5, v4 as uuidv4 } from "uuid"; +import { v5 as uuidv5 } from "uuid"; +import dayjs from "@calcom/dayjs"; import { prisma } from "@calcom/prisma"; -dayjs.extend(utc); - const translator = short(); type BookingFixture = ReturnType; diff --git a/apps/web/playwright/lib/appstore/wipe-my-cal.test.ts b/apps/web/playwright/lib/appstore/wipe-my-cal.test.ts index 38501dd703..934237b672 100644 --- a/apps/web/playwright/lib/appstore/wipe-my-cal.test.ts +++ b/apps/web/playwright/lib/appstore/wipe-my-cal.test.ts @@ -1,6 +1,6 @@ import { expect } from "@playwright/test"; -import dayjs from "dayjs"; +import dayjs from "@calcom/dayjs"; import prisma from "@calcom/prisma"; import { test } from "../../lib/fixtures"; diff --git a/apps/web/server/routers/viewer.tsx b/apps/web/server/routers/viewer.tsx index 83e5a519bf..0cb50c4309 100644 --- a/apps/web/server/routers/viewer.tsx +++ b/apps/web/server/routers/viewer.tsx @@ -1,11 +1,11 @@ import { BookingStatus, MembershipRole, AppCategories, Prisma } from "@prisma/client"; -import dayjs from "dayjs"; import _ from "lodash"; import { JSONObject } from "superjson/dist/types"; import { z } from "zod"; import getApps, { getLocationOptions } from "@calcom/app-store/utils"; import { getCalendarCredentials, getConnectedCalendars } from "@calcom/core/CalendarManager"; +import dayjs from "@calcom/dayjs"; import { checkPremiumUsername } from "@calcom/ee/lib/core/checkPremiumUsername"; import { sendFeedbackEmail } from "@calcom/emails"; import { sendCancelledEmails } from "@calcom/emails"; diff --git a/apps/web/server/routers/viewer/bookings.tsx b/apps/web/server/routers/viewer/bookings.tsx index daaeb41a77..ea19620ab8 100644 --- a/apps/web/server/routers/viewer/bookings.tsx +++ b/apps/web/server/routers/viewer/bookings.tsx @@ -1,8 +1,8 @@ import { SchedulingType } from "@prisma/client"; -import dayjs from "dayjs"; import { z } from "zod"; import EventManager from "@calcom/core/EventManager"; +import dayjs from "@calcom/dayjs"; import { sendLocationChangeEmails } from "@calcom/emails"; import { parseRecurringEvent } from "@calcom/lib"; import logger from "@calcom/lib/logger"; diff --git a/apps/web/server/routers/viewer/slots.tsx b/apps/web/server/routers/viewer/slots.tsx index 946cabd448..c1d187d007 100644 --- a/apps/web/server/routers/viewer/slots.tsx +++ b/apps/web/server/routers/viewer/slots.tsx @@ -1,11 +1,9 @@ import { SchedulingType } from "@prisma/client"; -import dayjs, { Dayjs } from "dayjs"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; import { z } from "zod"; import type { CurrentSeats } from "@calcom/core/getUserAvailability"; import { getUserAvailability } from "@calcom/core/getUserAvailability"; +import dayjs, { Dayjs } from "@calcom/dayjs"; import { yyyymmdd } from "@calcom/lib/date-fns"; import { availabilityUserSelect } from "@calcom/prisma"; import { stringToDayjs } from "@calcom/prisma/zod-utils"; @@ -17,9 +15,6 @@ import getSlots from "@lib/slots"; import { createRouter } from "@server/createRouter"; import { TRPCError } from "@trpc/server"; -dayjs.extend(utc); -dayjs.extend(timezone); - const getScheduleSchema = z .object({ // startTime ISOString diff --git a/apps/web/test/lib/getAvailabilityFromSchedule.test.ts b/apps/web/test/lib/getAvailabilityFromSchedule.test.ts index 51dfe6e0ca..04cafdce9f 100644 --- a/apps/web/test/lib/getAvailabilityFromSchedule.test.ts +++ b/apps/web/test/lib/getAvailabilityFromSchedule.test.ts @@ -1,12 +1,11 @@ import { expect, it } from "@jest/globals"; import { Availability } from "@prisma/client"; -import dayjs from "dayjs"; -import customParseFormat from "dayjs/plugin/customParseFormat"; import MockDate from "mockdate"; +import dayjs from "@calcom/dayjs"; + import { getAvailabilityFromSchedule } from "@lib/availability"; -dayjs.extend(customParseFormat); MockDate.set("2021-06-20T11:59:59Z"); //parse "hh:mm-hh:mm" into object diff --git a/apps/web/test/lib/getWorkingHours.test.ts b/apps/web/test/lib/getWorkingHours.test.ts index 626ff4b865..39e56db6f2 100644 --- a/apps/web/test/lib/getWorkingHours.test.ts +++ b/apps/web/test/lib/getWorkingHours.test.ts @@ -1,13 +1,9 @@ import { expect, it } from "@jest/globals"; -import dayjs from "dayjs"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; import MockDate from "mockdate"; -import { getWorkingHours } from "@lib/availability"; +import dayjs from "@calcom/dayjs"; -dayjs.extend(utc); -dayjs.extend(timezone); +import { getWorkingHours } from "@lib/availability"; MockDate.set("2021-06-20T11:59:59Z"); diff --git a/apps/web/test/lib/parseZone.test.ts b/apps/web/test/lib/parseZone.test.ts index 9eda945655..d6fee7943a 100644 --- a/apps/web/test/lib/parseZone.test.ts +++ b/apps/web/test/lib/parseZone.test.ts @@ -1,10 +1,5 @@ -import dayjs from "dayjs"; -import utc from "dayjs/plugin/utc"; - import { parseZone } from "@lib/parseZone"; -dayjs.extend(utc); - const EXPECTED_DATE_STRING = "2021-06-20T11:59:59+02:00"; it("has the right utcOffset regardless of the local timeZone", async () => { diff --git a/apps/web/test/lib/slots.test.ts b/apps/web/test/lib/slots.test.ts index b0a34720f1..38285b7ba9 100644 --- a/apps/web/test/lib/slots.test.ts +++ b/apps/web/test/lib/slots.test.ts @@ -1,16 +1,12 @@ import { expect, it } from "@jest/globals"; -import dayjs from "dayjs"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; import MockDate from "mockdate"; +import dayjs from "@calcom/dayjs"; + import { MINUTES_DAY_END, MINUTES_DAY_START } from "@lib/availability"; import { getFilteredTimes } from "@lib/hooks/useSlots"; import getSlots from "@lib/slots"; -dayjs.extend(utc); -dayjs.extend(timezone); - MockDate.set("2021-06-20T11:59:59Z"); it("can fit 24 hourly slots for an empty day", async () => { diff --git a/packages/app-store/slackmessaging/lib/actions/createEvent.ts b/packages/app-store/slackmessaging/lib/actions/createEvent.ts index 47456d0da2..a6f952daeb 100644 --- a/packages/app-store/slackmessaging/lib/actions/createEvent.ts +++ b/packages/app-store/slackmessaging/lib/actions/createEvent.ts @@ -1,5 +1,5 @@ import { WebClient } from "@slack/web-api"; -import dayjs from "dayjs"; +import dayjs from "@calcom/dayjs"; import { NextApiRequest, NextApiResponse } from "next"; import { z } from "zod"; diff --git a/packages/app-store/slackmessaging/lib/showTodayMessage.ts b/packages/app-store/slackmessaging/lib/showTodayMessage.ts index 3a62b83325..83517e7b9a 100644 --- a/packages/app-store/slackmessaging/lib/showTodayMessage.ts +++ b/packages/app-store/slackmessaging/lib/showTodayMessage.ts @@ -1,5 +1,5 @@ import { BookingStatus } from "@prisma/client"; -import dayjs from "dayjs"; +import dayjs from "@calcom/dayjs"; import { NextApiRequest, NextApiResponse } from "next"; import prisma from "@calcom/prisma"; diff --git a/packages/app-store/slackmessaging/lib/slackVerify.ts b/packages/app-store/slackmessaging/lib/slackVerify.ts index 52116d6ff9..f7915f5e4a 100644 --- a/packages/app-store/slackmessaging/lib/slackVerify.ts +++ b/packages/app-store/slackmessaging/lib/slackVerify.ts @@ -1,5 +1,5 @@ import { createHmac } from "crypto"; -import dayjs from "dayjs"; +import dayjs from "@calcom/dayjs"; import { NextApiRequest, NextApiResponse } from "next"; import { stringify } from "querystring"; diff --git a/packages/app-store/slackmessaging/lib/views/ShowLinks.ts b/packages/app-store/slackmessaging/lib/views/ShowLinks.ts index f4dce914fc..1d59c90bf4 100644 --- a/packages/app-store/slackmessaging/lib/views/ShowLinks.ts +++ b/packages/app-store/slackmessaging/lib/views/ShowLinks.ts @@ -1,4 +1,4 @@ -import dayjs from "dayjs"; +import dayjs from "@calcom/dayjs"; import { Blocks, Elements, Message } from "slack-block-builder"; import { WEBAPP_URL } from "@calcom/lib/constants"; diff --git a/packages/app-store/slackmessaging/lib/views/TodayMessage.ts b/packages/app-store/slackmessaging/lib/views/TodayMessage.ts index af304d0638..90c8f4101c 100644 --- a/packages/app-store/slackmessaging/lib/views/TodayMessage.ts +++ b/packages/app-store/slackmessaging/lib/views/TodayMessage.ts @@ -1,5 +1,5 @@ import { Booking } from "@prisma/client"; -import dayjs from "dayjs"; +import dayjs from "@calcom/dayjs"; import { Blocks, Elements, Message } from "slack-block-builder"; import { WEBAPP_URL } from "@calcom/lib/constants"; diff --git a/packages/app-store/vital/api/webhook.ts b/packages/app-store/vital/api/webhook.ts index 992b21b96a..4af3461f16 100644 --- a/packages/app-store/vital/api/webhook.ts +++ b/packages/app-store/vital/api/webhook.ts @@ -1,5 +1,5 @@ import { BookingStatus, Prisma } from "@prisma/client"; -import dayjs from "dayjs"; +import dayjs from "@calcom/dayjs"; import type { NextApiRequest, NextApiResponse } from "next"; import queue from "queue"; diff --git a/packages/app-store/vital/lib/reschedule.ts b/packages/app-store/vital/lib/reschedule.ts index be6e382349..efd306972b 100644 --- a/packages/app-store/vital/lib/reschedule.ts +++ b/packages/app-store/vital/lib/reschedule.ts @@ -1,5 +1,5 @@ import { Booking, BookingReference, BookingStatus, User } from "@prisma/client"; -import dayjs from "dayjs"; +import dayjs from "@calcom/dayjs"; import type { TFunction } from "next-i18next"; import EventManager from "@calcom/core/EventManager"; diff --git a/packages/app-store/wipemycalother/components/confirmDialog.tsx b/packages/app-store/wipemycalother/components/confirmDialog.tsx index 7be78bd983..fd586c5ca1 100644 --- a/packages/app-store/wipemycalother/components/confirmDialog.tsx +++ b/packages/app-store/wipemycalother/components/confirmDialog.tsx @@ -1,5 +1,5 @@ import { ClockIcon, XIcon } from "@heroicons/react/outline"; -import dayjs from "dayjs"; +import dayjs from "@calcom/dayjs"; import { Dispatch, SetStateAction } from "react"; import { useState } from "react"; import { useMutation } from "react-query"; diff --git a/packages/app-store/wipemycalother/lib/reschedule.ts b/packages/app-store/wipemycalother/lib/reschedule.ts index b042a4a862..23cbc23384 100644 --- a/packages/app-store/wipemycalother/lib/reschedule.ts +++ b/packages/app-store/wipemycalother/lib/reschedule.ts @@ -1,5 +1,5 @@ import { Booking, BookingReference, BookingStatus, User } from "@prisma/client"; -import dayjs from "dayjs"; +import dayjs from "@calcom/dayjs"; import type { TFunction } from "next-i18next"; import EventManager from "@calcom/core/EventManager"; diff --git a/packages/core/builders/CalendarEvent/builder.ts b/packages/core/builders/CalendarEvent/builder.ts index 4469708043..304b489a7a 100644 --- a/packages/core/builders/CalendarEvent/builder.ts +++ b/packages/core/builders/CalendarEvent/builder.ts @@ -1,5 +1,5 @@ import { Prisma, Booking } from "@prisma/client"; -import dayjs from "dayjs"; +import dayjs from "@calcom/dayjs"; import short from "short-uuid"; import { v5 as uuidv5 } from "uuid"; diff --git a/packages/core/getUserAvailability.ts b/packages/core/getUserAvailability.ts index fa185fac44..8af6ac6a28 100644 --- a/packages/core/getUserAvailability.ts +++ b/packages/core/getUserAvailability.ts @@ -1,5 +1,5 @@ import { Prisma } from "@prisma/client"; -import dayjs, { Dayjs } from "dayjs"; +import dayjs, { Dayjs } from "@calcom/dayjs"; import { z } from "zod"; import { getWorkingHours } from "@calcom/lib/availability"; diff --git a/packages/core/package.json b/packages/core/package.json index 712601fddc..ed5fdf1929 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -10,8 +10,8 @@ }, "dependencies": { "@calcom/app-store": "*", + "@calcom/dayjs": "*", "@calcom/lib": "*", - "dayjs": "^1.11.2", "ical.js": "^1.4.0", "ics": "^2.31.0", "uuid": "^8.3.2" diff --git a/packages/dayjs/index.ts b/packages/dayjs/index.ts new file mode 100644 index 0000000000..3ccfd77dea --- /dev/null +++ b/packages/dayjs/index.ts @@ -0,0 +1,26 @@ +import dayjs from "dayjs"; +import dayjsBusinessTime from "dayjs-business-days2"; +import customParseFormat from "dayjs/plugin/customParseFormat"; +import isBetween from "dayjs/plugin/isBetween"; +import isToday from "dayjs/plugin/isToday"; +import localizedFormat from "dayjs/plugin/localizedFormat"; +import relativeTime from "dayjs/plugin/relativeTime"; +import timeZone from "dayjs/plugin/timezone"; +import toArray from "dayjs/plugin/toArray"; +import utc from "dayjs/plugin/utc"; + +dayjs.extend(customParseFormat); +dayjs.extend(dayjsBusinessTime); +dayjs.extend(isBetween); +dayjs.extend(isToday); +dayjs.extend(localizedFormat); +dayjs.extend(relativeTime); +dayjs.extend(timeZone); +dayjs.extend(toArray); +dayjs.extend(utc); + +export type Dayjs = dayjs.Dayjs; + +export type { ConfigType } from "dayjs"; + +export default dayjs; diff --git a/packages/dayjs/package.json b/packages/dayjs/package.json new file mode 100644 index 0000000000..621e93ac8c --- /dev/null +++ b/packages/dayjs/package.json @@ -0,0 +1,10 @@ +{ + "name": "@calcom/dayjs", + "description": "Cal.com's Day.js shared library", + "version": "1.0.0", + "main": "./index.ts", + "dependencies": { + "dayjs": "^1.11.2", + "dayjs-business-days2": "^1.1.0" + } +} diff --git a/packages/emails/package.json b/packages/emails/package.json index b1e4d8b383..55b1716282 100644 --- a/packages/emails/package.json +++ b/packages/emails/package.json @@ -4,8 +4,8 @@ "private": true, "scripts": {}, "dependencies": { + "@calcom/dayjs": "*", "@calcom/lib": "*", - "dayjs": "^1.11.2", "next-i18next": "^11.0.0", "rrule": "^2.6.9" }, diff --git a/packages/emails/src/components/WhenInfo.tsx b/packages/emails/src/components/WhenInfo.tsx index af680ab77b..dab3311014 100644 --- a/packages/emails/src/components/WhenInfo.tsx +++ b/packages/emails/src/components/WhenInfo.tsx @@ -1,16 +1,13 @@ -import dayjs from "dayjs"; -import timezone from "dayjs/plugin/timezone"; import { TFunction } from "next-i18next"; import rrule from "rrule"; +import dayjs from "@calcom/dayjs"; import { getEveryFreqFor } from "@calcom/lib/recurringStrings"; import type { CalendarEvent } from "@calcom/types/Calendar"; import { RecurringEvent } from "@calcom/types/Calendar"; import { Info } from "./Info"; -dayjs.extend(timezone); - function getRecurringWhen({ calEvent }: { calEvent: CalendarEvent }) { if (calEvent.recurringEvent) { const t = calEvent.attendees[0].language.translate; diff --git a/packages/emails/src/templates/BaseScheduledEmail.tsx b/packages/emails/src/templates/BaseScheduledEmail.tsx index 882e673921..1f66469a97 100644 --- a/packages/emails/src/templates/BaseScheduledEmail.tsx +++ b/packages/emails/src/templates/BaseScheduledEmail.tsx @@ -1,10 +1,6 @@ -import dayjs from "dayjs"; -import localizedFormat from "dayjs/plugin/localizedFormat"; -import timezone from "dayjs/plugin/timezone"; -import toArray from "dayjs/plugin/toArray"; -import utc from "dayjs/plugin/utc"; import type { TFunction } from "next-i18next"; +import dayjs from "@calcom/dayjs"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; import { @@ -17,11 +13,6 @@ import { WhoInfo, } from "../components"; -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.extend(localizedFormat); -dayjs.extend(toArray); - export const BaseScheduledEmail = ( props: { calEvent: CalendarEvent; diff --git a/packages/emails/templates/_base-email.ts b/packages/emails/templates/_base-email.ts index 760fa8121e..e9e79d1045 100644 --- a/packages/emails/templates/_base-email.ts +++ b/packages/emails/templates/_base-email.ts @@ -1,18 +1,9 @@ -import dayjs, { Dayjs } from "dayjs"; -import localizedFormat from "dayjs/plugin/localizedFormat"; -import timezone from "dayjs/plugin/timezone"; -import toArray from "dayjs/plugin/toArray"; -import utc from "dayjs/plugin/utc"; import nodemailer from "nodemailer"; +import dayjs, { Dayjs } from "@calcom/dayjs"; import { getErrorFromUnknown } from "@calcom/lib/errors"; import { serverConfig } from "@calcom/lib/serverConfig"; -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.extend(localizedFormat); -dayjs.extend(toArray); - export default class BaseEmail { name = ""; diff --git a/packages/emails/templates/attendee-request-reschedule-email.ts b/packages/emails/templates/attendee-request-reschedule-email.ts index 02c73a0a06..fbc842e434 100644 --- a/packages/emails/templates/attendee-request-reschedule-email.ts +++ b/packages/emails/templates/attendee-request-reschedule-email.ts @@ -1,21 +1,12 @@ -import dayjs from "dayjs"; -import localizedFormat from "dayjs/plugin/localizedFormat"; -import timezone from "dayjs/plugin/timezone"; -import toArray from "dayjs/plugin/toArray"; -import utc from "dayjs/plugin/utc"; import { createEvent, DateArray, Person } from "ics"; +import dayjs from "@calcom/dayjs"; import { getCancelLink } from "@calcom/lib/CalEventParser"; import { CalendarEvent } from "@calcom/types/Calendar"; import { renderEmail } from "../"; import OrganizerScheduledEmail from "./organizer-scheduled-email"; -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.extend(localizedFormat); -dayjs.extend(toArray); - export default class AttendeeRequestRescheduledEmail extends OrganizerScheduledEmail { private metadata: { rescheduleLink: string }; constructor(calEvent: CalendarEvent, metadata: { rescheduleLink: string }) { diff --git a/packages/emails/templates/attendee-scheduled-email.ts b/packages/emails/templates/attendee-scheduled-email.ts index 226003b180..6d8d8cb8e1 100644 --- a/packages/emails/templates/attendee-scheduled-email.ts +++ b/packages/emails/templates/attendee-scheduled-email.ts @@ -1,23 +1,14 @@ -import dayjs from "dayjs"; -import localizedFormat from "dayjs/plugin/localizedFormat"; -import timezone from "dayjs/plugin/timezone"; -import toArray from "dayjs/plugin/toArray"; -import utc from "dayjs/plugin/utc"; import { createEvent, DateArray } from "ics"; import { TFunction } from "next-i18next"; import rrule from "rrule"; +import dayjs from "@calcom/dayjs"; import { getRichDescription } from "@calcom/lib/CalEventParser"; import type { CalendarEvent, Person } from "@calcom/types/Calendar"; import { renderEmail } from "../"; import BaseEmail from "./_base-email"; -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.extend(localizedFormat); -dayjs.extend(toArray); - export default class AttendeeScheduledEmail extends BaseEmail { calEvent: CalendarEvent; attendee: Person; diff --git a/packages/emails/templates/broken-integration-email.ts b/packages/emails/templates/broken-integration-email.ts index dc83db13be..96bcc90abc 100644 --- a/packages/emails/templates/broken-integration-email.ts +++ b/packages/emails/templates/broken-integration-email.ts @@ -1,11 +1,4 @@ -import dayjs from "dayjs"; -import localizedFormat from "dayjs/plugin/localizedFormat"; -import timezone from "dayjs/plugin/timezone"; -import toArray from "dayjs/plugin/toArray"; -import utc from "dayjs/plugin/utc"; -import { createEvent, DateArray, Person } from "ics"; import { TFunction } from "next-i18next"; -import rrule from "rrule"; import { getRichDescription } from "@calcom/lib/CalEventParser"; import type { CalendarEvent } from "@calcom/types/Calendar"; @@ -13,11 +6,6 @@ import type { CalendarEvent } from "@calcom/types/Calendar"; import { renderEmail } from ".."; import BaseEmail from "./_base-email"; -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.extend(localizedFormat); -dayjs.extend(toArray); - export default class BrokenIntegrationEmail extends BaseEmail { type: "calendar" | "video"; calEvent: CalendarEvent; diff --git a/packages/emails/templates/organizer-request-reschedule-email.ts b/packages/emails/templates/organizer-request-reschedule-email.ts index fc69d04f9e..5de6e4698d 100644 --- a/packages/emails/templates/organizer-request-reschedule-email.ts +++ b/packages/emails/templates/organizer-request-reschedule-email.ts @@ -1,20 +1,11 @@ -import dayjs from "dayjs"; -import localizedFormat from "dayjs/plugin/localizedFormat"; -import timezone from "dayjs/plugin/timezone"; -import toArray from "dayjs/plugin/toArray"; -import utc from "dayjs/plugin/utc"; import { createEvent, DateArray, Person } from "ics"; +import dayjs from "@calcom/dayjs"; import { CalendarEvent } from "@calcom/types/Calendar"; import { renderEmail } from "../"; import OrganizerScheduledEmail from "./organizer-scheduled-email"; -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.extend(localizedFormat); -dayjs.extend(toArray); - export default class OrganizerRequestRescheduledEmail extends OrganizerScheduledEmail { private metadata: { rescheduleLink: string }; constructor(calEvent: CalendarEvent, metadata: { rescheduleLink: string }) { diff --git a/packages/emails/templates/organizer-scheduled-email.ts b/packages/emails/templates/organizer-scheduled-email.ts index 623451ee5c..e76501e209 100644 --- a/packages/emails/templates/organizer-scheduled-email.ts +++ b/packages/emails/templates/organizer-scheduled-email.ts @@ -1,23 +1,14 @@ -import dayjs from "dayjs"; -import localizedFormat from "dayjs/plugin/localizedFormat"; -import timezone from "dayjs/plugin/timezone"; -import toArray from "dayjs/plugin/toArray"; -import utc from "dayjs/plugin/utc"; import { createEvent, DateArray, Person } from "ics"; import { TFunction } from "next-i18next"; import rrule from "rrule"; +import dayjs from "@calcom/dayjs"; import { getRichDescription } from "@calcom/lib/CalEventParser"; import type { CalendarEvent } from "@calcom/types/Calendar"; import { renderEmail } from "../"; import BaseEmail from "./_base-email"; -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.extend(localizedFormat); -dayjs.extend(toArray); - export default class OrganizerScheduledEmail extends BaseEmail { calEvent: CalendarEvent; t: TFunction; diff --git a/packages/lib/CalendarService.ts b/packages/lib/CalendarService.ts index 964b228d5e..bba56a5595 100644 --- a/packages/lib/CalendarService.ts +++ b/packages/lib/CalendarService.ts @@ -1,9 +1,5 @@ /// import { Credential, Prisma } from "@prisma/client"; -import dayjs from "dayjs"; -import isBetween from "dayjs/plugin/isBetween"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; import ICAL from "ical.js"; import { Attendee, createEvent, DateArray, DurationObject, Person } from "ics"; import { @@ -18,6 +14,7 @@ import { } from "tsdav"; import { v4 as uuidv4 } from "uuid"; +import dayjs from "@calcom/dayjs"; import type { Calendar, CalendarEvent, @@ -35,10 +32,6 @@ import logger from "./logger"; const TIMEZONE_FORMAT = "YYYY-MM-DDTHH:mm:ss[Z]"; const DEFAULT_CALENDAR_TYPE = "caldav"; -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.extend(isBetween); - const CALENDSO_ENCRYPTION_KEY = process.env.CALENDSO_ENCRYPTION_KEY || ""; const convertDate = (date: string): DateArray => diff --git a/packages/lib/availability.ts b/packages/lib/availability.ts index 7c5ba630c5..6a472c54a4 100644 --- a/packages/lib/availability.ts +++ b/packages/lib/availability.ts @@ -1,16 +1,10 @@ import type { Availability } from "@prisma/client"; -import dayjs, { ConfigType } from "dayjs"; -import customParseFormat from "dayjs/plugin/customParseFormat"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; +import dayjs, { ConfigType } from "@calcom/dayjs"; import type { Schedule, TimeRange, WorkingHours } from "@calcom/types/schedule"; import { nameOfDay } from "./weekday"; -dayjs.extend(utc); -dayjs.extend(timezone); -dayjs.extend(customParseFormat); // sets the desired time in current date, needs to be current date for proper DST translation export const defaultDayRange: TimeRange = { start: new Date(new Date().setUTCHours(9, 0, 0, 0)), diff --git a/packages/lib/date-fns/index.ts b/packages/lib/date-fns/index.ts index 4fe08fb1af..4f59201147 100644 --- a/packages/lib/date-fns/index.ts +++ b/packages/lib/date-fns/index.ts @@ -1,4 +1,4 @@ -import dayjs, { Dayjs } from "dayjs"; +import dayjs, { Dayjs } from "@calcom/dayjs"; // converts a date to 2022-04-25 for example. export const yyyymmdd = (date: Date | Dayjs) => diff --git a/packages/lib/package.json b/packages/lib/package.json index 7ddbfa6188..a3e1014275 100644 --- a/packages/lib/package.json +++ b/packages/lib/package.json @@ -5,9 +5,9 @@ "types": "./index.ts", "license": "MIT", "dependencies": { + "@calcom/dayjs": "*", "@prisma/client": "^3.15.2", "bcryptjs": "^2.4.3", - "dayjs": "^1.11.2", "ical.js": "^1.4.0", "ics": "^2.31.0", "next-i18next": "^11.0.0", diff --git a/packages/prisma/seed.ts b/packages/prisma/seed.ts index c4b0f08c5e..c9eb8436b9 100644 --- a/packages/prisma/seed.ts +++ b/packages/prisma/seed.ts @@ -1,7 +1,7 @@ import { BookingStatus, MembershipRole, Prisma, UserPlan } from "@prisma/client"; -import dayjs from "dayjs"; import { uuid } from "short-uuid"; +import dayjs from "@calcom/dayjs"; import { hashPassword } from "@calcom/lib/auth"; import { DEFAULT_SCHEDULE, getAvailabilityFromSchedule } from "@calcom/lib/availability"; diff --git a/packages/prisma/zod-utils.ts b/packages/prisma/zod-utils.ts index 5de576caaa..7b25c2bfe5 100644 --- a/packages/prisma/zod-utils.ts +++ b/packages/prisma/zod-utils.ts @@ -1,15 +1,9 @@ -import dayjs from "dayjs"; -import timezone from "dayjs/plugin/timezone"; -import utc from "dayjs/plugin/utc"; import { z } from "zod"; import { LocationType } from "@calcom/core/location"; +import dayjs from "@calcom/dayjs"; import { slugify } from "@calcom/lib/slugify"; -// -dayjs.extend(utc); -dayjs.extend(timezone); - // Let's not import 118kb just to get an enum export enum Frequency { YEARLY = 0, diff --git a/packages/stripe/downgrade.ts b/packages/stripe/downgrade.ts index 91e8ec4afd..71e309fefe 100755 --- a/packages/stripe/downgrade.ts +++ b/packages/stripe/downgrade.ts @@ -1,8 +1,8 @@ #!/usr/bin/env ts-node // To run this script: `yarn downgrade 2>&1 | tee result.log` import { Prisma, UserPlan } from "@prisma/client"; -import dayjs from "dayjs"; +import dayjs from "@calcom/dayjs"; import { TRIAL_LIMIT_DAYS } from "@calcom/lib/constants"; import prisma from "@calcom/prisma"; import stripe from "@calcom/stripe/server"; diff --git a/packages/stripe/package.json b/packages/stripe/package.json index c19c309a77..e302ee925c 100644 --- a/packages/stripe/package.json +++ b/packages/stripe/package.json @@ -11,11 +11,11 @@ "ts-node": "^10.6.0" }, "dependencies": { + "@calcom/dayjs": "*", "@calcom/ee": "*", "@calcom/lib": "*", "@stripe/react-stripe-js": "^1.8.0", "@stripe/stripe-js": "^1.29.0", - "dayjs": "^1.11.2", "stripe": "^9.1.0" }, "main": "index.ts", diff --git a/packages/ui/booker/DatePicker.tsx b/packages/ui/booker/DatePicker.tsx index 0a691ecc6d..ad7f555bd7 100644 --- a/packages/ui/booker/DatePicker.tsx +++ b/packages/ui/booker/DatePicker.tsx @@ -1,14 +1,11 @@ import { ChevronLeftIcon, ChevronRightIcon } from "@heroicons/react/solid"; -import dayjs, { Dayjs } from "dayjs"; -import isToday from "dayjs/plugin/isToday"; +import dayjs, { Dayjs } from "@calcom/dayjs"; import classNames from "@calcom/lib/classNames"; import { daysInMonth, yyyymmdd } from "@calcom/lib/date-fns"; import { weekdayNames } from "@calcom/lib/weekday"; import { SkeletonText } from "@calcom/ui/skeleton"; -dayjs.extend(isToday); - export type DatePickerProps = { /** which day of the week to render the calendar. Usually Sunday (=0) or Monday (=1) - default: Sunday */ weekStart?: 0 | 1 | 2 | 3 | 4 | 5 | 6;