[PR #346] [MERGED] feat(ui): add 12h/24h time format option with locale-aware default (#342) #8611

Closed
opened 2026-08-26 00:57:20 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/RayLabsHQ/gitea-mirror/pull/346
Author: @arunavo4
Created: 7/16/2026
Status: ✅ Merged
Merged: 7/16/2026
Merged by: @arunavo4

Base: main ← Head: feat/342-24h-time-option


📝 Commits (1)

  • 285ba78 feat(ui): add 12h/24h time format option with locale-aware default (#342)

📊 Changes

12 files changed (+508 additions, -21 deletions)

View changed files

📝 src/components/activity/ActivityList.tsx (+4 -0)
📝 src/components/config/AutomationSettings.tsx (+4 -0)
📝 src/components/config/ScheduleConfigForm.tsx (+4 -0)
📝 src/components/dashboard/Dashboard.tsx (+7 -9)
📝 src/components/dashboard/RecentActivity.tsx (+4 -0)
📝 src/components/layout/Header.tsx (+3 -0)
➕ src/components/layout/TimeFormatToggle.tsx (+52 -0)
➕ src/hooks/useTimeFormat.ts (+31 -0)
📝 src/lib/utils.test.ts (+6 -5)
📝 src/lib/utils.ts (+3 -7)
➕ src/lib/utils/time-format.test.ts (+231 -0)
➕ src/lib/utils/time-format.ts (+159 -0)

📄 Description

Summary

Fixes #342 — adds a 24-hour time option. It turned out the UI wasn't following the browser locale at all: formatDate() in src/lib/utils.ts and the Dashboard "Last Sync" card hardcoded en-US (+ hour12: true), forcing 12-hour AM/PM for everyone.

Changes

  • New shared utility src/lib/utils/time-format.ts — all UI timestamp formatting goes through it (formatDateTime, formatShortDateTime, formatTime).
  • Locale-aware default: with no preference set, times follow the browser locale's convention (24h locales get 24h automatically).
  • Explicit toggle: clock icon in the header next to the theme toggle — Auto / 12-hour / 24-hour — persisted in localStorage (same pattern as the theme; no DB/schema changes for a pure display preference).
  • Instant updates: useTimeFormat() hook (useSyncExternalStore over a custom event + native storage event) so all mounted timestamp components re-render on change, incl. cross-tab.
  • Applied across: activity log (+ CSV/JSON exports), dashboard recent activity + Last Sync card, scheduler info (last/next sync, cleanup runs).
  • Intentionally untouched: server-generated strings (mirrored issue bodies, rate-limit log messages) stay deterministic; repo lists use relative times only.

Testing

  • bun test: 399 pass, 0 fail
  • 17 new tests in src/lib/utils/time-format.test.ts: preference validation, localStorage round-trip + corrupted-value fallback, subscribe/unsubscribe + cross-tab storage events, 24h forced on en-US, 12h forced on de-DE, auto follows locale, ISO/epoch input equivalence — all timezone-agnostic

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/RayLabsHQ/gitea-mirror/pull/346 **Author:** [@arunavo4](https://github.com/arunavo4) **Created:** 7/16/2026 **Status:** ✅ Merged **Merged:** 7/16/2026 **Merged by:** [@arunavo4](https://github.com/arunavo4) **Base:** `main` ← **Head:** `feat/342-24h-time-option` --- ### 📝 Commits (1) - [`285ba78`](https://github.com/RayLabsHQ/gitea-mirror/commit/285ba7817756b95b7fabb16385e77cd576e0ea69) feat(ui): add 12h/24h time format option with locale-aware default (#342) ### 📊 Changes **12 files changed** (+508 additions, -21 deletions) <details> <summary>View changed files</summary> 📝 `src/components/activity/ActivityList.tsx` (+4 -0) 📝 `src/components/config/AutomationSettings.tsx` (+4 -0) 📝 `src/components/config/ScheduleConfigForm.tsx` (+4 -0) 📝 `src/components/dashboard/Dashboard.tsx` (+7 -9) 📝 `src/components/dashboard/RecentActivity.tsx` (+4 -0) 📝 `src/components/layout/Header.tsx` (+3 -0) ➕ `src/components/layout/TimeFormatToggle.tsx` (+52 -0) ➕ `src/hooks/useTimeFormat.ts` (+31 -0) 📝 `src/lib/utils.test.ts` (+6 -5) 📝 `src/lib/utils.ts` (+3 -7) ➕ `src/lib/utils/time-format.test.ts` (+231 -0) ➕ `src/lib/utils/time-format.ts` (+159 -0) </details> ### 📄 Description ## Summary Fixes #342 — adds a 24-hour time option. It turned out the UI wasn't following the browser locale at all: `formatDate()` in `src/lib/utils.ts` and the Dashboard "Last Sync" card hardcoded `en-US` (+ `hour12: true`), forcing 12-hour AM/PM for everyone. ## Changes - **New shared utility** `src/lib/utils/time-format.ts` — all UI timestamp formatting goes through it (`formatDateTime`, `formatShortDateTime`, `formatTime`). - **Locale-aware default**: with no preference set, times follow the browser locale's convention (24h locales get 24h automatically). - **Explicit toggle**: clock icon in the header next to the theme toggle — Auto / 12-hour / 24-hour — persisted in `localStorage` (same pattern as the theme; no DB/schema changes for a pure display preference). - **Instant updates**: `useTimeFormat()` hook (`useSyncExternalStore` over a custom event + native `storage` event) so all mounted timestamp components re-render on change, incl. cross-tab. - Applied across: activity log (+ CSV/JSON exports), dashboard recent activity + Last Sync card, scheduler info (last/next sync, cleanup runs). - Intentionally untouched: server-generated strings (mirrored issue bodies, rate-limit log messages) stay deterministic; repo lists use relative times only. ## Testing - `bun test`: 399 pass, 0 fail - 17 new tests in `src/lib/utils/time-format.test.ts`: preference validation, localStorage round-trip + corrupted-value fallback, subscribe/unsubscribe + cross-tab storage events, 24h forced on en-US, 12h forced on de-DE, auto follows locale, ISO/epoch input equivalence — all timezone-agnostic --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-08-26 00:57:20 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/gitea-mirror#8611