Skip to content

fix: normalize Supabase date formats for Safari compatibility (Fixes #642)#673

Closed
lb1192176991-lab wants to merge 2 commits into
ritesh-1918:gssocfrom
lb1192176991-lab:fix/safari-date-parsing-642-1780106724
Closed

fix: normalize Supabase date formats for Safari compatibility (Fixes #642)#673
lb1192176991-lab wants to merge 2 commits into
ritesh-1918:gssocfrom
lb1192176991-lab:fix/safari-date-parsing-642-1780106724

Conversation

@lb1192176991-lab
Copy link
Copy Markdown

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 formatTimelineDate function assumed all browsers handle date strings identically, but Safari is stricter about ISO 8601 compliance.

Changes to Frontend/src/utils/dateUtils.js:

  • Added a new parseDateSafely() helper with explicit regex-based handling for all Supabase date output formats
  • "YYYY-MM-DD HH:MM:SS" (space separator) — Safari fails on this, now parsed via Date.UTC() constructor
  • "YYYY-MM-DD" (date-only) — explicit constructor instead of relying on new Date() heuristic
  • Raw strings without timezone — normalized to UTC with explicit +Z
  • Strings with explicit timezone — pass through to standard new Date() (safe in all browsers)
  • Number timestamps — handled directly via 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

  1. Open the Ticket Timeline page in Safari (desktop or iOS)
  2. Verify all ticket dates display correctly as "DD Mon YYYY, HH:MM AM/PM"
  3. Verify ticket dates with space-separated format render correctly
  4. Verify date-only fields render correctly
  5. Cross-check the same pages in Chrome/Firefox — output should be identical

…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
@vercel
Copy link
Copy Markdown

vercel Bot commented May 30, 2026

@lb1192176991-lab is attempting to deploy a commit to the ritesh Team on Vercel.

A member of the Team first needs to authorize it.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 30, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 114497ca-fc95-47c2-9938-45793a39ccf0

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

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

Comment thread Frontend/src/utils/dateUtils.js Outdated
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;
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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.
@lb1192176991-lab
Copy link
Copy Markdown
Author

Superseded by PR #663 which has a cleaner approach — same fix but rebased.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant