Consolidates dayjs in a single package

This commit is contained in:
zomars 2022-06-28 14:40:58 -06:00
parent 5be669a479
commit 7122a4a91d
80 changed files with 120 additions and 299 deletions

View File

@ -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;

View File

@ -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";

View File

@ -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";

View File

@ -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;

View File

@ -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) => {

View File

@ -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,

View File

@ -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";

View File

@ -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";

View File

@ -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 }) {

View File

@ -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<PaymentPageProps> = (props) => {
const { t } = useLocale();
const [is24h, setIs24h] = useState(isBrowserLocale24h());

View File

@ -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];

View File

@ -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";

View File

@ -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(
[

View File

@ -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;

View File

@ -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();

View File

@ -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;

View File

@ -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,

View File

@ -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";

View File

@ -1,4 +1,4 @@
import dayjs from "dayjs";
import dayjs from "@calcom/dayjs";
const ISO8601_OFFSET_FORMAT = /^(.*)([+-])(\d{2}):(\d{2})|(Z)$/;

View File

@ -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;

View File

@ -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",

View File

@ -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",

View File

@ -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";

View File

@ -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<typeof getServerSideProps>;
export default function Book(props: BookPageProps) {

View File

@ -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";

View File

@ -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"] });

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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;

View File

@ -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";

View File

@ -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 }) => {

View File

@ -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";

View File

@ -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<typeof getServerSideProps>;
export default function Book(props: HashLinkPageProps) {

View File

@ -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;

View File

@ -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;
};

View File

@ -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;
}

View File

@ -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";

View File

@ -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";

View File

@ -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<typeof createBookingFixture>;

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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

View File

@ -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 <Availability> object

View File

@ -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");

View File

@ -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 () => {

View File

@ -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 () => {

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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";

View File

@ -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"

26
packages/dayjs/index.ts Normal file
View File

@ -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;

View File

@ -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"
}
}

View File

@ -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"
},

View File

@ -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;

View File

@ -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;

View File

@ -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 = "";

View File

@ -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 }) {

View File

@ -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;

View File

@ -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;

View File

@ -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 }) {

View File

@ -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;

View File

@ -1,9 +1,5 @@
/// <reference path="../types/ical.d.ts"/>
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 =>

View File

@ -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)),

View File

@ -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) =>

View File

@ -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",

View File

@ -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";

View File

@ -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,

View File

@ -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";

View File

@ -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",

View File

@ -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;