-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[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
base: preview
Are you sure you want to change the base?
Conversation
WalkthroughA new helper function, Changes
Suggested labels
Poem
✨ Finishing Touches
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed 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)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Pull Request Linked with Plane Work Items
Comment Automatically Generated by Plane |
There was a problem hiding this 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
andgetDate
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
📒 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 withrenderSafeFormattedDate
provides several benefits:
- Error resilience: Handles invalid or undefined dates gracefully instead of throwing errors
- Timezone safety: Leverages the timezone-safe parsing pipeline via
getDate
function- Consistent fallback: Shows "Invalid date" for problematic dates instead of crashing
- Maintained format: Preserves the existing "MMM dd, yyyy" display format
This directly addresses the PR objective of fixing timezone conversion issues for cycle dates.
Description
This update renders the safe formatted date, avoiding unnecessary date conversions for the start date and end date in cycles.
Type of Change
Summary by CodeRabbit