From 13edfdcf1a1f7af270c2b9974e95b35a9157d873 Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Wed, 29 Apr 2026 20:32:51 -0400 Subject: [PATCH] feat(ui): use timezone-aware time formatting across all templates Replace hardcoded .Format() calls with FormatInTimezone() and FormatTimestamptzInTimezone() helpers so all timestamps display in the user's selected timezone. Changes: - book_detail.templ: remove incorrect templates. package prefix - book_detail_modals.templ: add User param to ProgressSyncModal so timezone is available; convert Timestamp to FormatInTimezone() - devices.templ: convert LastSync and LastSeen to FormatInTimezone() - conflicts.templ: convert CreatedAt to FormatInTimezone() - admin_users.templ: convert CreatedAt to FormatInTimezone() using currentUser.Timezone Note: DatePublished is kept as a plain date format (MM-DD-YYYY) since it is a pgtype.Date, not a timestamp, and does not need timezone conversion. --- templates/admin_users.templ | 2 +- templates/book_detail.templ | 4 ++-- templates/book_detail_modals.templ | 4 ++-- templates/conflicts.templ | 2 +- templates/devices.templ | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/templates/admin_users.templ b/templates/admin_users.templ index 8953a28..0a9e8ad 100644 --- a/templates/admin_users.templ +++ b/templates/admin_users.templ @@ -86,7 +86,7 @@ templ AdminUsers(currentUser User, users []User, adminCount int) { -
{ user.CreatedAt.Format("01-02-2006") }
+
{ FormatInTimezone(user.CreatedAt, currentUser.Timezone) }
diff --git a/templates/book_detail.templ b/templates/book_detail.templ index a0db0b6..3614b85 100644 --- a/templates/book_detail.templ +++ b/templates/book_detail.templ @@ -250,7 +250,7 @@ templ BookDetail(user User, book handlers.MediaDetail, errorMessage string) { if book.ReadingProgress.LastReadAt.Valid {

Last Read

-

{ templates.FormatTimestamptzInTimezone(book.ReadingProgress.LastReadAt, user.Timezone) }

+

{ FormatTimestamptzInTimezone(book.ReadingProgress.LastReadAt, user.Timezone) }

} if book.ReadingProgress.LastSyncSource.Valid { @@ -501,7 +501,7 @@ templ BookDetail(user User, book handlers.MediaDetail, errorMessage string) { } - @ProgressSyncModal(book) + @ProgressSyncModal(user, book) @NotesHighlightsModal(book) @ErrorToast(errorMessage) diff --git a/templates/book_detail_modals.templ b/templates/book_detail_modals.templ index b5fe655..3d58f49 100644 --- a/templates/book_detail_modals.templ +++ b/templates/book_detail_modals.templ @@ -6,7 +6,7 @@ import ( ) // ProgressSyncModal shows progress from all devices for manual review -templ ProgressSyncModal(book handlers.MediaDetail) { +templ ProgressSyncModal(user User, book handlers.MediaDetail) {
diff --git a/templates/conflicts.templ b/templates/conflicts.templ index d8bb326..1eb1b67 100644 --- a/templates/conflicts.templ +++ b/templates/conflicts.templ @@ -111,7 +111,7 @@ templ Conflicts(user User, conflicts []handlers.ConflictDetailResponse, total in
- Created: { conflict.CreatedAt.Format("01-02-2006 03:04:05 PM") } + Created: { FormatInTimezone(conflict.CreatedAt, user.Timezone) } if conflict.ResolvedBy != "" { | Resolved by: { conflict.ResolvedBy } } diff --git a/templates/devices.templ b/templates/devices.templ index 2f8141e..aaee178 100644 --- a/templates/devices.templ +++ b/templates/devices.templ @@ -80,7 +80,7 @@ templ Devices(user User, devices []handlers.DeviceInfo, pendingRegistrations []P
Last Sync if device.LastSync != nil { - { device.LastSync.Format("01-02-2006 03:04 PM") } + { FormatInTimezone(*device.LastSync, user.Timezone) } } else { Never } @@ -88,7 +88,7 @@ templ Devices(user User, devices []handlers.DeviceInfo, pendingRegistrations []P
Last Seen if device.LastSeen != nil { - { device.LastSeen.Format("01-02-2006 03:04 PM") } + { FormatInTimezone(*device.LastSeen, user.Timezone) } } else { Never }