Skip to content

Fix deterministic editorial date formatting - #56

Merged
xrendan merged 1 commit into
mainfrom
fix/deterministic-editorial-dates
Aug 11, 2026
Merged

Fix deterministic editorial date formatting#56
xrendan merged 1 commit into
mainfrom
fix/deterministic-editorial-dates

Conversation

@xrendan

@xrendan xrendan commented Aug 11, 2026

Copy link
Copy Markdown
Member

Summary

  • centralize editorial date formatting in the America/Toronto timezone
  • use the shared formatter for memo cards, memo engagement, feed cards, and state-of-the-nation chart labels
  • preserve date-only chart periods by anchoring them at noon UTC before Toronto formatting

Why

React hydration error 418 was caused by server and browser renders selecting different calendar days for the same timestamp. Recent PostHog samples reference an older cached bundle, but additional unpinned client date formatters remained in the current code.

Validation

  • pnpm exec tsc --noEmit --incremental false
  • targeted ESLint: no errors; one existing no-img-element warning in the Open Graph chart renderer
  • formatter output matched under UTC, America/Edmonton, and Asia/Tokyo

@greptile-apps

greptile-apps Bot commented Aug 11, 2026

Copy link
Copy Markdown

Greptile Summary

Centralizes editorial date rendering around an America/Toronto formatter to prevent server/client calendar-day differences.

  • Adds shared short-date, long-date, and month-year formatting helpers with invalid-value handling.
  • Anchors date-only values at noon UTC so chart periods retain their intended Toronto calendar date.
  • Applies the shared helpers to memo, engagement, feed, canvas-chart, and Open Graph labels.

Confidence Score: 5/5

The PR appears safe to merge, with the affected date paths consistently using the intended editorial timezone.

The shared formatter handles invalid inputs, preserves date-only chart periods, and runs on supported Node.js and browser targets; no concrete blocking or non-blocking defect remains.

Important Files Changed

Filename Overview
src/lib/date-format.ts Introduces deterministic Toronto date formatters and safely preserves bare calendar dates through noon-UTC anchoring.
src/app/memos/[slug]/MemoEngagement.tsx Replaces UTC engagement-date formatting with the shared editorial timezone behavior.
src/app/state-of-the-nation/canvas/OverlayChart.tsx Routes monthly tooltip labels through the shared deterministic formatter.
src/app/state-of-the-nation/og-card.tsx Uses shared month formatting for chart labels while retaining the annual fallback for invalid or absent dates.
src/app/memos/types.ts Makes memo-list date formatting deterministic across server and browser rendering.
src/components/feed/types.ts Makes feed-card publication dates deterministic in the editorial timezone.
src/components/ui/memo-card.tsx Consolidates existing Toronto memo-card formatting into the shared helper without changing fallback behavior.

Reviews (1): Last reviewed commit: "Fix deterministic editorial date formatt..." | Re-trigger Greptile

@xrendan
xrendan merged commit dbd2474 into main Aug 11, 2026
2 checks passed
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