Skip to content

[WEB-4277]fix: timezone conversion for cycles dates #7180

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

Open
wants to merge 1 commit into
base: preview
Choose a base branch
from

Conversation

vamsikrishnamathala
Copy link
Member

@vamsikrishnamathala vamsikrishnamathala commented Jun 6, 2025

Description

This update renders the safe formatted date, avoiding unnecessary date conversions for the start date and end date in cycles.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • Feature (non-breaking change which adds functionality)
  • Improvement (change that would cause existing functionality to not work as expected)
  • Code refactoring
  • Performance improvements
  • Documentation update

Summary by CodeRabbit

  • New Features
    • Improved date formatting for cycle start and end dates, providing more robust and user-friendly date displays with graceful handling of invalid or missing dates.

Copy link
Contributor

coderabbitai bot commented Jun 6, 2025

Walkthrough

A new helper function, renderSafeFormattedDate, was introduced to provide robust date formatting with fallback handling. The cycle list item component was updated to use this helper for displaying start and end dates, replacing direct usage of date-fns formatting to improve date display reliability.

Changes

File(s) Change Summary
web/helpers/date-time.helper.ts Added renderSafeFormattedDate utility for safe date formatting with fallback support.
web/core/components/cycles/list/cycle-list-item-action.tsx Updated to use renderSafeFormattedDate for displaying cycle start and end dates in tooltips.

Suggested labels

ready to merge

Poem

A hop and a skip, the dates now shine bright,
With helpers to catch what once gave us fright.
No more invalid, no more dismay—
Just formatted dates, the rabbit’s new way!
🗓️✨

✨ Finishing Touches
  • 📝 Generate Docstrings

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

Copy link

makeplane bot commented Jun 6, 2025

Pull Request Linked with Plane Work Items

Comment Automatically Generated by Plane

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
web/helpers/date-time.helper.ts (1)

479-512: LGTM! Robust implementation with comprehensive fallback handling.

The function effectively addresses the timezone conversion issues mentioned in the PR objectives by leveraging the existing renderFormattedPayloadDate and getDate utilities that handle timezone-safe parsing. The defensive programming approach with multiple validation layers and try-catch error handling ensures reliable date formatting.

Consider this minor optimization to reduce the double conversion overhead:

export const renderSafeFormattedDate = (
  date: Date | string | undefined | null,
  formatToken: string = "MMM dd, yyyy",
  fallback: string = "Invalid date"
): string => {
  if (!date) return fallback;

-  // Use renderFormattedPayloadDate to get a properly formatted payload date
-  const payloadDate = renderFormattedPayloadDate(date);
-
-  // If renderFormattedPayloadDate returns undefined/null, return fallback
-  if (!payloadDate) return fallback;
-
  try {
-    // Parse and format the payload date
-    const parsedDate = getDate(payloadDate);
+    // Parse the date directly using the timezone-safe getDate function
+    const parsedDate = getDate(date);
    if (!parsedDate || !isValid(parsedDate)) return fallback;

    return format(parsedDate, formatToken);
  } catch (error) {
    // Return fallback if any error occurs during formatting
    return fallback;
  }
};

However, the current implementation ensures maximum consistency with the existing payload date normalization pipeline.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f6ea4f9 and 66cfb3d.

📒 Files selected for processing (2)
  • web/core/components/cycles/list/cycle-list-item-action.tsx (2 hunks)
  • web/helpers/date-time.helper.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
web/core/components/cycles/list/cycle-list-item-action.tsx (1)
web/helpers/date-time.helper.ts (1)
  • renderSafeFormattedDate (489-512)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: Analyze (javascript)
🔇 Additional comments (2)
web/core/components/cycles/list/cycle-list-item-action.tsx (2)

26-26: LGTM! Correct import of the new safe date formatter.

The import correctly includes the new renderSafeFormattedDate helper function.


233-238: Excellent improvement! Safe date formatting with proper fallback handling.

The replacement of direct format(parseISO(...), "MMM dd, yyyy") calls with renderSafeFormattedDate provides several benefits:

  1. Error resilience: Handles invalid or undefined dates gracefully instead of throwing errors
  2. Timezone safety: Leverages the timezone-safe parsing pipeline via getDate function
  3. Consistent fallback: Shows "Invalid date" for problematic dates instead of crashing
  4. Maintained format: Preserves the existing "MMM dd, yyyy" display format

This directly addresses the PR objective of fixing timezone conversion issues for cycle dates.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛bug Something isn't working ready to merge
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants