Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 35 additions & 12 deletions apps/web/modules/bookings/views/bookings-single-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1229,8 +1229,21 @@ function RecurringBookings({
<div key={idx} className={classNames("mb-2", isCancelled ? "line-through" : "")}>
{formatToLocalizedDate(dayjs.tz(dateStr, tz), language, "full", tz)}
<br />
{formatToLocalizedTime(dayjs(dateStr), language, undefined, !is24h, tz)} -{" "}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we're passing an object to formatToLocalizedTime we don't need to pass undefined as a param here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are still setting timeStyle to undefined in the new object argument format, I think we should have skipped that.

{formatToLocalizedTime(dayjs(dateStr).add(duration, "m"), language, undefined, !is24h, tz)}{" "}
{formatToLocalizedTime({
date: dayjs(dateStr),
locale: language,
timeStyle: undefined,
hour12: !is24h,
timeZone: tz,
})}{" "}
-{" "}
{formatToLocalizedTime({
date: dayjs(dateStr).add(duration, "m"),
locale: language,
timeStyle: undefined,
hour12: !is24h,
timeZone: tz,
})}{" "}
<span className="text-bookinglight">
({formatToLocalizedTimezone(dayjs(dateStr), language, tz)})
</span>
Expand All @@ -1249,14 +1262,19 @@ function RecurringBookings({
<div key={idx} className={classNames("mb-2", isCancelled ? "line-through" : "")}>
{formatToLocalizedDate(dayjs.tz(dateStr, tz), language, "full", tz)}
<br />
{formatToLocalizedTime(dayjs(dateStr), language, undefined, !is24h, tz)} -{" "}
{formatToLocalizedTime(
dayjs(dateStr).add(duration, "m"),
language,
undefined,
!is24h,
tz
)}{" "}
{formatToLocalizedTime({
date: dayjs(dateStr),
locale: language,
hour12: !is24h,
timeZone: tz,
})}{" "}
-{" "}
{formatToLocalizedTime({
date: dayjs(dateStr).add(duration, "m"),
locale: language,
hour12: !is24h,
timeZone: tz,
})}{" "}
Comment on lines +1265 to +1277
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: It might be better to have a fn that does returns this time range. It seems to be a duplicate here. Same as above.

<span className="text-bookinglight">
({formatToLocalizedTimezone(dayjs(dateStr), language, tz)})
</span>
Expand All @@ -1273,8 +1291,13 @@ function RecurringBookings({
<div className={classNames(isCancelled ? "line-through" : "")}>
{formatToLocalizedDate(date, language, "full", tz)}
<br />
{formatToLocalizedTime(date, language, undefined, !is24h, tz)} -{" "}
{formatToLocalizedTime(dayjs(date).add(duration, "m"), language, undefined, !is24h, tz)}{" "}
{formatToLocalizedTime({ date, locale: language, hour12: !is24h, timeZone: tz })} -{" "}
{formatToLocalizedTime({
date: dayjs(date).add(duration, "m"),
locale: language,
hour12: !is24h,
timeZone: tz,
})}{" "}
Comment on lines +1294 to +1300
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one too is duplicate it seems

<span className="text-bookinglight">({formatToLocalizedTimezone(date, language, tz)})</span>
</div>
);
Expand Down
5 changes: 3 additions & 2 deletions apps/web/modules/videos/views/videos-single-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -288,6 +288,7 @@ export function VideoMeetingInfo(props: VideoMeetingInfo) {

const endTime = new Date(booking.endTime);
const startTime = new Date(booking.startTime);
const timeZone = booking.user?.timeZone;

useDailyEvent("left-meeting", () => {
if (rediectAttendeeToOnExit) {
Expand All @@ -306,11 +307,11 @@ export function VideoMeetingInfo(props: VideoMeetingInfo) {
<h3>{t("what")}:</h3>
<p>{booking.title}</p>
<h3>{t("invitee_timezone")}:</h3>
<p>{booking.user?.timeZone}</p>
<p>{timeZone}</p>
<h3>{t("when")}:</h3>
<p suppressHydrationWarning={true}>
{formatToLocalizedDate(startTime)} <br />
{formatToLocalizedTime(startTime)}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Timezone wasn't being passed even though we're displaying it in the sidebar.

{formatToLocalizedTime({ date: startTime, timeZone })}
</p>
<h3>{t("time_left")}</h3>
<ProgressBar
Expand Down
20 changes: 13 additions & 7 deletions packages/lib/dayjs/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,19 @@ export const formatToLocalizedDate = (
* given Date object and locale. Undefined values mean the defaults
* associated with the browser's current locale will be used.
*/
export const formatToLocalizedTime = (
date: Date | Dayjs,
locale: string | undefined = undefined,
timeStyle: Intl.DateTimeFormatOptions["timeStyle"] = "short",
hour12: Intl.DateTimeFormatOptions["hour12"] = undefined,
timeZone?: string
) => formatLocalizedDateTime(date, { timeStyle, hour12, timeZone }, locale);
export const formatToLocalizedTime = ({
date,
locale = undefined,
timeStyle = "short",
hour12 = undefined,
timeZone,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it make sense to make timeZone a required field, so that goign forward this timeZone isn't accidentally missed

}: {
date: Date | Dayjs;
locale?: string | undefined;
timeStyle?: Intl.DateTimeFormatOptions["timeStyle"];
hour12?: Intl.DateTimeFormatOptions["hour12"];
timeZone?: string;
}) => formatLocalizedDateTime(date, { timeStyle, hour12, timeZone }, locale);

/**
* Returns a translated timezone based on the given Date object and
Expand Down
Loading