mirror of
https://github.com/harvard-edge/cs249r_book.git
synced 2026-07-16 14:42:29 -05:00
[PR #1911] [MERGED] fix(staffml): format Footer build date in UTC to avoid hydration mismatch #36526
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/harvard-edge/cs249r_book/pull/1911
Author: @farhan523
Created: 6/28/2026
Status: ✅ Merged
Merged: 7/10/2026
Merged by: @profvjreddi
Base:
dev← Head:fix/footer-hydration-utc📝 Commits (1)
1a1f247fix(staffml): format Footer build date in UTC to avoid hydration mismatch📊 Changes
2 files changed (+61 additions, -0 deletions)
View changed files
➕
interviews/staffml/src/__tests__/footer-build-label.test.tsx(+52 -0)📝
interviews/staffml/src/components/Footer.tsx(+9 -0)📄 Description
Summary
Footerrenderednew Date(BUILD_DATE).toLocaleDateString(\"en-US\", {...})without atimeZoneoption, so the build date formatted in the runtime's local TZ. With Next's static export the HTML is generated at build time on the build server (UTC in CI) and hydrates on the client whenever the user visits. Near day/year boundaries the two TZs disagree:That's both a hydration-mismatch warning and a wrong label — the build is from Dec 31 UTC, not Jan 1 in the viewer's TZ.
Changes
timeZone: \"UTC\"to thetoLocaleDateStringoptions so the label reflects the canonical build instant.This is the matching fix for the same pattern shipped in PR #1843 for
PaperCitationCard.Test plan
npx vitest run→ 128/128 across 23 files passing (was already green; +2 new cases on the new Footer test file).npx tsc --noEmit→ clean./about,/contribute) — the footer'sVault v... · <Month> <Day>, <Year>should match the BUILD_DATE in UTC, not your local date.Test coverage
The regression test mocks
@/lib/statswithBUILD_DATE = 2025-01-01T01:00:00Z(Jan 1 2025 UTC, but Dec 31 2024 in PT) and asserts the label reads "Jan 1, 2025" even whenvi.setSystemTimeputs "now" in a completely different year. If the formatting ever regresses to use the runtime clock or the runtime TZ, both tests fail immediately.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.