fix: normalize Supabase date formats for Safari compatibility (Fixes #642)#673
Conversation
…itesh-1918#642) Safari fails to parse ISO-8601 timestamps without explicit timezone info and dates using space separators instead of "T". - Adds explicit regex-based date parsing for all Supabase output formats - Space-separated "YYYY-MM-DD HH:MM:SS" → Date.UTC() construction - Date-only "YYYY-MM-DD" → explicit constructor - Raw strings without TZ → UTC normalization - Fallback to original new Date() for known-good formats
|
@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: 0e1336e986
ℹ️ 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".
| const spaceMatch = trimmed.match(DATETIME_SPACE_REGEX); | ||
| if (spaceMatch) { | ||
| const [, y, m, d, h, min, s, ms] = spaceMatch; | ||
| const msVal = ms ? parseInt(ms.padEnd(3, '0')) : 0; |
There was a problem hiding this comment.
Truncate fractional seconds before Date.UTC
For space-separated Supabase/Postgres timestamps with microsecond precision such as 2024-01-01 00:00:00.123456, this parses 123456 as milliseconds; Date.UTC then rolls that into 00:02:03.456 instead of 00:00:00.123. Since Postgres timestamps commonly include six fractional digits, Safari users can see timeline entries shifted by minutes/seconds whenever the affected format includes fractional seconds; slice to the first three digits before padding/parsing.
Useful? React with 👍 / 👎.
The regex captures the full fractional-second string from Postgres timestamps. When that string contains six digits (microsecond precision, e.g. .123456), parseInt interprets the value as 123456 ms = 2 min 3 sec, shifting the rendered time by minutes. Slice to 3 digits first to match millisecond precision expected by Date.UTC.
|
Superseded by PR #663 which has a cleaner approach — same fix but rebased. |
What
Safari browsers fail to parse certain ISO-8601 timestamps returned from Supabase on the Ticket Timeline, leading to "Invalid Date" or blank displays. The existing
formatTimelineDatefunction assumed all browsers handle date strings identically, but Safari is stricter about ISO 8601 compliance.Changes to
Frontend/src/utils/dateUtils.js:parseDateSafely()helper with explicit regex-based handling for all Supabase date output formatsDate.UTC()constructornew Date()heuristic+Znew Date()(safe in all browsers)new Date(number)Why
Users on Safari (iOS and macOS) see blank or "Invalid Date" entries on the Ticket Timeline, making the core feature unusable on Apple devices. The fix ensures all supported Supabase output formats render correctly across Safari, Firefox, and Chrome.
Testing