Skip to content

Commit 9193221

Browse files
authored
fix: Cal Video sidebar not showing meeting time in timezone (calcom#22821)
* Pass params as object to `formatToLocalizedTime` * Refactor videos-single-view * Refactor bookings-single-view
1 parent f81bb92 commit 9193221

3 files changed

Lines changed: 51 additions & 21 deletions

File tree

apps/web/modules/bookings/views/bookings-single-view.tsx

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1229,8 +1229,21 @@ function RecurringBookings({
12291229
<div key={idx} className={classNames("mb-2", isCancelled ? "line-through" : "")}>
12301230
{formatToLocalizedDate(dayjs.tz(dateStr, tz), language, "full", tz)}
12311231
<br />
1232-
{formatToLocalizedTime(dayjs(dateStr), language, undefined, !is24h, tz)} -{" "}
1233-
{formatToLocalizedTime(dayjs(dateStr).add(duration, "m"), language, undefined, !is24h, tz)}{" "}
1232+
{formatToLocalizedTime({
1233+
date: dayjs(dateStr),
1234+
locale: language,
1235+
timeStyle: undefined,
1236+
hour12: !is24h,
1237+
timeZone: tz,
1238+
})}{" "}
1239+
-{" "}
1240+
{formatToLocalizedTime({
1241+
date: dayjs(dateStr).add(duration, "m"),
1242+
locale: language,
1243+
timeStyle: undefined,
1244+
hour12: !is24h,
1245+
timeZone: tz,
1246+
})}{" "}
12341247
<span className="text-bookinglight">
12351248
({formatToLocalizedTimezone(dayjs(dateStr), language, tz)})
12361249
</span>
@@ -1249,14 +1262,19 @@ function RecurringBookings({
12491262
<div key={idx} className={classNames("mb-2", isCancelled ? "line-through" : "")}>
12501263
{formatToLocalizedDate(dayjs.tz(dateStr, tz), language, "full", tz)}
12511264
<br />
1252-
{formatToLocalizedTime(dayjs(dateStr), language, undefined, !is24h, tz)} -{" "}
1253-
{formatToLocalizedTime(
1254-
dayjs(dateStr).add(duration, "m"),
1255-
language,
1256-
undefined,
1257-
!is24h,
1258-
tz
1259-
)}{" "}
1265+
{formatToLocalizedTime({
1266+
date: dayjs(dateStr),
1267+
locale: language,
1268+
hour12: !is24h,
1269+
timeZone: tz,
1270+
})}{" "}
1271+
-{" "}
1272+
{formatToLocalizedTime({
1273+
date: dayjs(dateStr).add(duration, "m"),
1274+
locale: language,
1275+
hour12: !is24h,
1276+
timeZone: tz,
1277+
})}{" "}
12601278
<span className="text-bookinglight">
12611279
({formatToLocalizedTimezone(dayjs(dateStr), language, tz)})
12621280
</span>
@@ -1273,8 +1291,13 @@ function RecurringBookings({
12731291
<div className={classNames(isCancelled ? "line-through" : "")}>
12741292
{formatToLocalizedDate(date, language, "full", tz)}
12751293
<br />
1276-
{formatToLocalizedTime(date, language, undefined, !is24h, tz)} -{" "}
1277-
{formatToLocalizedTime(dayjs(date).add(duration, "m"), language, undefined, !is24h, tz)}{" "}
1294+
{formatToLocalizedTime({ date, locale: language, hour12: !is24h, timeZone: tz })} -{" "}
1295+
{formatToLocalizedTime({
1296+
date: dayjs(date).add(duration, "m"),
1297+
locale: language,
1298+
hour12: !is24h,
1299+
timeZone: tz,
1300+
})}{" "}
12781301
<span className="text-bookinglight">({formatToLocalizedTimezone(date, language, tz)})</span>
12791302
</div>
12801303
);

apps/web/modules/videos/views/videos-single-view.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,7 @@ export function VideoMeetingInfo(props: VideoMeetingInfo) {
288288

289289
const endTime = new Date(booking.endTime);
290290
const startTime = new Date(booking.startTime);
291+
const timeZone = booking.user?.timeZone;
291292

292293
useDailyEvent("left-meeting", () => {
293294
if (rediectAttendeeToOnExit) {
@@ -306,11 +307,11 @@ export function VideoMeetingInfo(props: VideoMeetingInfo) {
306307
<h3>{t("what")}:</h3>
307308
<p>{booking.title}</p>
308309
<h3>{t("invitee_timezone")}:</h3>
309-
<p>{booking.user?.timeZone}</p>
310+
<p>{timeZone}</p>
310311
<h3>{t("when")}:</h3>
311312
<p suppressHydrationWarning={true}>
312313
{formatToLocalizedDate(startTime)} <br />
313-
{formatToLocalizedTime(startTime)}
314+
{formatToLocalizedTime({ date: startTime, timeZone })}
314315
</p>
315316
<h3>{t("time_left")}</h3>
316317
<ProgressBar

packages/lib/dayjs/index.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -79,13 +79,19 @@ export const formatToLocalizedDate = (
7979
* given Date object and locale. Undefined values mean the defaults
8080
* associated with the browser's current locale will be used.
8181
*/
82-
export const formatToLocalizedTime = (
83-
date: Date | Dayjs,
84-
locale: string | undefined = undefined,
85-
timeStyle: Intl.DateTimeFormatOptions["timeStyle"] = "short",
86-
hour12: Intl.DateTimeFormatOptions["hour12"] = undefined,
87-
timeZone?: string
88-
) => formatLocalizedDateTime(date, { timeStyle, hour12, timeZone }, locale);
82+
export const formatToLocalizedTime = ({
83+
date,
84+
locale = undefined,
85+
timeStyle = "short",
86+
hour12 = undefined,
87+
timeZone,
88+
}: {
89+
date: Date | Dayjs;
90+
locale?: string | undefined;
91+
timeStyle?: Intl.DateTimeFormatOptions["timeStyle"];
92+
hour12?: Intl.DateTimeFormatOptions["hour12"];
93+
timeZone?: string;
94+
}) => formatLocalizedDateTime(date, { timeStyle, hour12, timeZone }, locale);
8995

9096
/**
9197
* Returns a translated timezone based on the given Date object and

0 commit comments

Comments
 (0)