fix(platform): display timestamps in user's local timezone#700
Conversation
… UTC Pass the browser's timezone (via Intl.DateTimeFormat) through all useFormatDate hooks so dates render in the user's local timezone. Replace TableDateCell with new CopyableTimestamp component in the documents table that shows the long-format date and lets power users copy the raw Unix timestamp. Add Storybook stories for the new component. Closes #691
There was a problem hiding this comment.
Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.
📝 WalkthroughWalkthroughThis change introduces timezone-aware timestamp display functionality to resolve UTC timezone issues in document timestamps. It adds a new Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 4
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@services/platform/app/components/ui/data-display/copyable-timestamp.tsx`:
- Around line 65-67: The rendered timestamp lacks timezone context: update the
logic around formatted and titleText in copyable-timestamp.tsx to include
timezone information (use dateObj/timezone or Intl.DateTimeFormat with
timeZoneName or extend formatDate to accept a timezone flag) so both the
displayed formatted value (formatted) and the hover/title (titleText) append or
incorporate the time zone indicator (e.g., "UTC", "PST", or an offset)
consistent with the preset; locate usages of formatDate, formatted, titleText
and ensure the chosen timezone string is derived from dateObj or passed props
and concatenated into the final output.
- Line 133: The visually hidden copied state in the CopyableTimestamp component
should be placed in an ARIA live region so screen readers announce updates; find
the span rendering {copied && <span
className="sr-only">{tCommon('actions.copied')}</span>} and change it to an ARIA
live status (e.g., <span className="sr-only" role="status" aria-live="polite"
aria-atomic="true">...) so the "copied" text is announced when copied is
toggled.
- Around line 102-118: The copy button is always visible because it lacks
hidden-by-default + hover-reveal styles; update the parent span (the one using
cn('inline-flex items-center gap-1', ...)) to be a hover group (e.g., add a
"group" class) and change the button element (the <button> with class
"hover:bg-muted shrink-0 ...", aria-label using tCommon('actions.copy')) to be
hidden by default and become visible on group hover and on button focus (so
keyboard users can reveal it). Ensure you use the same unique identifiers: the
parent wrapper span where cn(...) is used and the copy button in
copyable-timestamp.tsx, and keep existing alignment logic (alignRight/className)
intact.
- Around line 59-66: The CopyableTimestamp component currently converts string
dates via new Date(date) (see dateObj/timestampMs/formatted/titleText) which
breaks formatDate's UTC-normalization; either tighten the prop type on
CopyableTimestamp to only accept number | Date (removing string) or, if string
support is required, stop converting string to a Date and pass the original
string into formatDate so it can apply its 'Z' UTC-normalization; update the
date prop type and usages (or the conditional creating dateObj) accordingly and
ensure timestampMs still yields a numeric string when date is a number or Date.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: ASSERTIVE
Plan: Pro
Run ID: 11fd1e0d-5856-44f8-a327-73913ef730eb
📒 Files selected for processing (4)
services/platform/app/components/ui/data-display/copyable-timestamp.stories.tsxservices/platform/app/components/ui/data-display/copyable-timestamp.tsxservices/platform/app/features/documents/hooks/use-documents-table-config.tsxservices/platform/app/hooks/use-format-date.ts
Timestamps with time info (long/time presets) now display the short timezone abbreviation (e.g. CET, PST) directly in the rendered text instead of only in the hover tooltip, making the timezone context immediately visible without user interaction.
Summary
Intl.DateTimeFormat) through alluseFormatDatehooks so dates render in the user's local timezone instead of UTCCopyableTimestampcomponent that shows a formatted date with a copy button for the raw Unix timestampTableDateCellwithCopyableTimestampin the documents table, using thelongpreset for better readabilityCopyableTimestampcovering all presets and edge casesCloses #691
Test plan
🤖 Generated with Claude Code
Summary by CodeRabbit