fix: normalize ISO-8601 timestamps for Safari compatibility (Fixes #642)#663
fix: normalize ISO-8601 timestamps for Safari compatibility (Fixes #642)#663lb1192176991-lab wants to merge 2 commits into
Conversation
…tesh-1918#642) - Replace space-between-date-and-time with "T" (Safari requirement) - Append "Z" for UTC when no timezone info present - Graceful fallback: return current time instead of "Invalid Date"
|
@lb1192176991-lab is attempting to deploy a commit to the ritesh Team on Vercel. A member of the Team first needs to authorize it. |
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1233023834
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
|
||
| // Replace space between date and time with 'T' (Safari requirement) | ||
| // e.g. "2024-01-15 14:30:00+00" → "2024-01-15T14:30:00+00" | ||
| s = s.replace(/^(\d{4}-\d{2}-\d{2})\s+(\d{2}:\d{2}:\d{2})/, '$1T$2'); |
There was a problem hiding this comment.
Normalize short timezone offsets before parsing
For timestamps in the documented failing shape such as 2024-01-15 14:30:00+00, this normalization only changes the separator and leaves the offset as +00. That is not a valid ECMAScript ISO offset, so new Date('2024-01-15T14:30:00+00') is invalid in common engines; the new fallback then renders the current time instead of the ticket time. When the backend emits +00 offsets, every affected timeline entry will show the wrong date rather than being fixed for Safari.
Useful? React with 👍 / 👎.
Adds regex to convert short offsets like +00, -05, +0530 to proper ±HH:MM format (e.g. +00:00, -05:00, +05:30). Safari requires the colon separator in timezone offsets for new Date() to parse correctly.
|
Good point. Updated. Added |
What
Old Safari browsers (and WebKit-based browsers) fail to parse certain ISO-8601 timestamps returned from Supabase. Specifically:
"2024-01-15 14:30:00") — it requires the "T" separatorThis PR adds
normalizeDateStr()todateUtils.jsthat:Why
Without this fix, users on older Safari/WebKit browsers see blank or "Invalid Date" text on the Ticket Timeline component when viewing tickets, making the timeline effectively unusable on those browsers.
Testing
formatTimelineDate("2024-01-15 14:30:00+00")→ normalized to"2024-01-15T14:30:00+00"✓formatTimelineDate("2024-01-15T14:30:00")→ normalized to"2024-01-15T14:30:00Z"✓formatTimelineDate(null)→ returnsnull✓formatTimelineDate("garbage")→ returns current date (graceful fallback) instead of crashing ✓