Skip to content

fix: Cal Video sidebar not showing meeting time in timezone #22821

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jul 31, 2025

Conversation

joeauyeung
Copy link
Contributor

What does this PR do?

  • Refactors formatToLocalizedTime to accept an object instead of multiple params
  • One videos-single-view pass timezone to formatToLocalizedTime

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. If N/A, write N/A here and check the checkbox.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

  • Create a Cal Video booking
  • On the sidebar, it should show the formatted time

Copy link
Contributor

coderabbitai bot commented Jul 30, 2025

Walkthrough

The changes refactor the formatToLocalizedTime function in the shared date utility library to accept a single options object parameter instead of multiple positional arguments. Corresponding updates are made in the RecurringBookings component within the bookings module and the VideoMeetingInfo component within the videos module to call this function with the new argument structure. Additionally, in the videos view, the invitee's timezone is now assigned to a local constant before use. No changes are made to the underlying formatting logic or control flow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

  • Complexity: Simple refactor to function signatures and call sites; no changes to logic or control flow.
  • Scope: Affects one utility function and its usage in two components.
  • Review time: Estimated at around 8 minutes due to the need to verify type safety, function usage consistency, and the absence of behavioral changes.

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 32d2fd5 and 8acba9e.

📒 Files selected for processing (3)
  • apps/web/modules/bookings/views/bookings-single-view.tsx (3 hunks)
  • apps/web/modules/videos/views/videos-single-view.tsx (2 hunks)
  • packages/lib/dayjs/index.ts (1 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
**/*.ts

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

**/*.ts: For Prisma queries, only select data you need; never use include, always use select
Ensure the credential.key field is never returned from tRPC endpoints or APIs

Files:

  • packages/lib/dayjs/index.ts
**/*.{ts,tsx}

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Files:

  • packages/lib/dayjs/index.ts
  • apps/web/modules/videos/views/videos-single-view.tsx
  • apps/web/modules/bookings/views/bookings-single-view.tsx
**/*.tsx

📄 CodeRabbit Inference Engine (.cursor/rules/review.mdc)

Always use t() for text localization in frontend code; direct text embedding should trigger a warning

Files:

  • apps/web/modules/videos/views/videos-single-view.tsx
  • apps/web/modules/bookings/views/bookings-single-view.tsx
🧠 Learnings (4)
📓 Common learnings
Learnt from: CR
PR: calcom/cal.com#0
File: .cursor/rules/review.mdc:0-0
Timestamp: 2025-07-28T11:50:23.946Z
Learning: Applies to **/*.{ts,tsx} : Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js `.utc()` in hot paths like loops
packages/lib/dayjs/index.ts (1)

Learnt from: CR
PR: calcom/cal.com#0
File: .cursor/rules/review.mdc:0-0
Timestamp: 2025-07-28T11:50:23.946Z
Learning: Applies to **/*.{ts,tsx} : Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

apps/web/modules/videos/views/videos-single-view.tsx (1)

Learnt from: CR
PR: calcom/cal.com#0
File: .cursor/rules/review.mdc:0-0
Timestamp: 2025-07-28T11:50:23.946Z
Learning: Applies to **/*.{ts,tsx} : Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

apps/web/modules/bookings/views/bookings-single-view.tsx (3)

Learnt from: CR
PR: calcom/cal.com#0
File: .cursor/rules/review.mdc:0-0
Timestamp: 2025-07-28T11:50:23.946Z
Learning: Applies to **/*.{ts,tsx} : Flag excessive Day.js use in performance-critical code; prefer native Date or Day.js .utc() in hot paths like loops

Learnt from: eunjae-lee
PR: #22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.389Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.

Learnt from: CR
PR: calcom/cal.com#0
File: .cursor/rules/review.mdc:0-0
Timestamp: 2025-07-28T11:50:23.946Z
Learning: Applies to **/*.tsx : Always use t() for text localization in frontend code; direct text embedding should trigger a warning

🔇 Additional comments (6)
apps/web/modules/videos/views/videos-single-view.tsx (2)

291-291: LGTM! Good refactor to centralize timezone access.

Extracting the timezone to a local constant improves readability and avoids repeated property access.


310-314: LGTM! Correctly updated to use new function signature.

The formatToLocalizedTime call correctly uses the new object parameter format with date and timeZone properties, maintaining the same functionality while adopting the refactored API.

apps/web/modules/bookings/views/bookings-single-view.tsx (3)

232-246: LGTM! Correctly refactored to use object parameters.

Both formatToLocalizedTime calls properly use the new object parameter format with all required properties (date, locale, hour12, timeZone) and explicitly set timeStyle to undefined, maintaining the original functionality.


265-277: LGTM! Consistent with the refactor pattern.

The formatToLocalizedTime calls in the collapsible section correctly use the new object parameter format, maintaining consistency with the rest of the component.


294-300: LGTM! Final set of calls correctly updated.

The remaining formatToLocalizedTime calls for single bookings properly use the new object parameter format, completing the consistent refactor across the entire component.

packages/lib/dayjs/index.ts (1)

82-94: LGTM! Excellent API refactor with named parameters.

The refactor from positional to named parameters significantly improves the function's usability:

  • Makes function calls more readable and self-documenting
  • Reduces likelihood of parameter order errors
  • Provides sensible defaults for optional parameters
  • Maintains type safety with proper TypeScript annotations

The implementation correctly passes all parameters to formatLocalizedDateTime.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch pass-timezone-to-video-info

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@graphite-app graphite-app bot requested a review from a team July 30, 2025 15:17
@keithwillcode keithwillcode added core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO labels Jul 30, 2025
@@ -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.

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

@dosubot dosubot bot added bookings area: bookings, availability, timezones, double booking 🐛 bug Something isn't working labels Jul 30, 2025
Copy link

graphite-app bot commented Jul 30, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (07/30/25)

1 reviewer was added to this PR based on Keith Williams's automation.

Copy link
Contributor

E2E results are ready!

Comment on lines +1265 to +1277
{formatToLocalizedTime({
date: dayjs(dateStr),
locale: language,
hour12: !is24h,
timeZone: tz,
})}{" "}
-{" "}
{formatToLocalizedTime({
date: dayjs(dateStr).add(duration, "m"),
locale: language,
hour12: !is24h,
timeZone: tz,
})}{" "}
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.

Comment on lines +1294 to +1300
{formatToLocalizedTime({ date, locale: language, hour12: !is24h, timeZone: tz })} -{" "}
{formatToLocalizedTime({
date: dayjs(date).add(duration, "m"),
locale: language,
hour12: !is24h,
timeZone: tz,
})}{" "}
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

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

Copy link
Member

@hariombalhara hariombalhara left a comment

Choose a reason for hiding this comment

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

Just nit comments regarding code cleanup, otherwise it is good !!

@joeauyeung joeauyeung merged commit 9193221 into main Jul 31, 2025
107 of 112 checks passed
@joeauyeung joeauyeung deleted the pass-timezone-to-video-info branch July 31, 2025 20:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bookings area: bookings, availability, timezones, double booking 🐛 bug Something isn't working core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ready-for-e2e
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants