Skip to content

fix: normalize ISO-8601 timestamps for Safari compatibility (Fixes #642)#663

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

fix: normalize ISO-8601 timestamps for Safari compatibility (Fixes #642)#663
lb1192176991-lab wants to merge 2 commits into
ritesh-1918:gssocfrom
lb1192176991-lab:fix/safari-date-parsing-642

Conversation

@lb1192176991-lab
Copy link
Copy Markdown

What

Old Safari browsers (and WebKit-based browsers) fail to parse certain ISO-8601 timestamps returned from Supabase. Specifically:

  1. Safari rejects space-separated date+time ("2024-01-15 14:30:00") — it requires the "T" separator
  2. Timestamps without explicit timezone info may be interpreted incorrectly
  3. Invalid/corrupt dates throw exceptions instead of degrading gracefully

This PR adds normalizeDateStr() to dateUtils.js that:

  • Replaces space-between-date-and-time with "T" (Safari requirement)
  • Appends "Z" for UTC when no timezone info is present after normalization
  • Falls back gracefully to the current timestamp when the input is unparseable

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) → returns null
  • formatTimelineDate("garbage") → returns current date (graceful fallback) instead of crashing ✓
  • Existing ISO formats with Z suffix continue to work unchanged ✓

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

vercel Bot commented May 29, 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 29, 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: 811621d2-b588-44e5-b8b4-6f7c8f08b3d1

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: 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');
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

Good point. Updated.

Added /([+-])(\d{2})(\d{2})?$/ regex normalization to convert short timezone offsets (+00, -05, +0530) to proper ±HH:MM format (+00:00, -05:00, +05:30). Now new Date('2024-01-15T14:30:00+00:00') parses correctly in Safari.

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