From e5726e12be2d533ed52f5c443730e7d52900558a Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Mon, 27 Apr 2026 21:31:19 -0400 Subject: [PATCH] Switch all user-facing time displays to 12-hour MM-DD-YYYY format Consistently format dates and times across all templates and API handlers using MM-DD-YYYY with 12-hour clock (03:04 PM): - analytics.go: date keys, lastSync, lastRead timestamps - progress.go: lastUpdated timestamp in GetAllProgress - book_detail.templ: LastReadAt, DatePublished - book_detail_modals.templ: progress sync timestamps, LastReadAt - devices.templ: LastSync, LastSeen - conflicts.templ: CreatedAt - admin_users.templ: user CreatedAt date --- internal/handlers/analytics.go | 16 ++++++++-------- internal/handlers/progress.go | 2 +- templates/admin_users.templ | 2 +- templates/admin_users_templ.go | 2 +- templates/book_detail.templ | 6 +++--- templates/book_detail_modals.templ | 4 ++-- templates/book_detail_modals_templ.go | 8 ++++---- templates/book_detail_templ.go | 8 ++++---- templates/conflicts.templ | 2 +- templates/conflicts_templ.go | 4 ++-- templates/devices.templ | 4 ++-- templates/devices_templ.go | 8 ++++---- 12 files changed, 33 insertions(+), 33 deletions(-) diff --git a/internal/handlers/analytics.go b/internal/handlers/analytics.go index 9df4a66..1b0644e 100644 --- a/internal/handlers/analytics.go +++ b/internal/handlers/analytics.go @@ -75,18 +75,18 @@ func (h *AnalyticsHandler) GetReadingStats(c *echo.Context) error { endDate := c.QueryParam("end_date") if startDate == "" { - startDate = time.Now().AddDate(0, -1, 0).Format("2006-01-02") + startDate = time.Now().AddDate(0, -1, 0).Format("01-02-2006") } if endDate == "" { - endDate = time.Now().Format("2006-01-02") + endDate = time.Now().Format("01-02-2006") } - startTime, err := time.Parse("2006-01-02", startDate) + startTime, err := time.Parse("01-02-2006", startDate) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, "invalid start_date format") } - endTime, err := time.Parse("2006-01-02", endDate) + endTime, err := time.Parse("01-02-2006", endDate) if err != nil { return echo.NewHTTPError(http.StatusBadRequest, "invalid end_date format") } @@ -130,7 +130,7 @@ func (h *AnalyticsHandler) calculateReadingStats(history []database.GetUserReadi longestSession = int(minutes) } - dateKey := entry.CreatedAt.Time.Format("2006-01-02") + dateKey := entry.CreatedAt.Time.Format("01-02-2006") if dailyMap[dateKey] == nil { dailyMap[dateKey] = &DailyReading{ Date: dateKey, @@ -141,7 +141,7 @@ func (h *AnalyticsHandler) calculateReadingStats(history []database.GetUserReadi if entry.PagesRead.Valid { totalPages += int(entry.PagesRead.Int32) - dateKey := entry.CreatedAt.Time.Format("2006-01-02") + dateKey := entry.CreatedAt.Time.Format("01-02-2006") if dailyMap[dateKey] != nil { dailyMap[dateKey].Pages += int(entry.PagesRead.Int32) } @@ -222,7 +222,7 @@ func (h *AnalyticsHandler) GetDeviceUsage(c *echo.Context) error { lastSync := "" if u.LastSync != nil { if t, ok := u.LastSync.(time.Time); ok { - lastSync = t.Format("2006-01-02 15:04:05") + lastSync = t.Format("01-02-2006 03:04:05 PM") } } @@ -274,7 +274,7 @@ func (h *AnalyticsHandler) GetPopularBooks(c *echo.Context) error { lastRead := "" if book.LastRead != nil { if t, ok := book.LastRead.(time.Time); ok { - lastRead = t.Format("2006-01-02 15:04:05") + lastRead = t.Format("01-02-2006 03:04:05 PM") } } diff --git a/internal/handlers/progress.go b/internal/handlers/progress.go index f10946e..0af5ea9 100644 --- a/internal/handlers/progress.go +++ b/internal/handlers/progress.go @@ -306,7 +306,7 @@ func (h *Handler) GetAllProgress(c *echo.Context) error { lastUpdated := "" if progress.LastReadAt.Valid { - lastUpdated = progress.LastReadAt.Time.Format("2006-01-02 15:04") + lastUpdated = progress.LastReadAt.Time.Format("01-02-2006 03:04 PM") } progressList = append(progressList, ProgressWithMedia{ diff --git a/templates/admin_users.templ b/templates/admin_users.templ index 6a4a803..8953a28 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("2006-01-02") }
+
{ user.CreatedAt.Format("01-02-2006") }
diff --git a/templates/admin_users_templ.go b/templates/admin_users_templ.go index 2f5adde..8bfff80 100644 --- a/templates/admin_users_templ.go +++ b/templates/admin_users_templ.go @@ -178,7 +178,7 @@ func AdminUsers(currentUser User, users []User, adminCount int) templ.Component return templ_7745c5c3_Err } var templ_7745c5c3_Var8 string - templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(user.CreatedAt.Format("2006-01-02")) + templ_7745c5c3_Var8, templ_7745c5c3_Err = templ.JoinStringErrs(user.CreatedAt.Format("01-02-2006")) if templ_7745c5c3_Err != nil { return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/admin_users.templ`, Line: 89, Col: 106} } diff --git a/templates/book_detail.templ b/templates/book_detail.templ index dd04a6d..a132634 100644 --- a/templates/book_detail.templ +++ b/templates/book_detail.templ @@ -229,7 +229,7 @@ templ BookDetail(user User, book handlers.MediaDetail, errorMessage string) {
@@ -250,7 +250,7 @@ templ BookDetail(user User, book handlers.MediaDetail, errorMessage string) { if book.ReadingProgress.LastReadAt.Valid {

Last Read

-

{ book.ReadingProgress.LastReadAt.Time.Format("2006-01-02 15:04") }

+

{ book.ReadingProgress.LastReadAt.Time.Format("01-02-2006 03:04 PM") }

} if book.ReadingProgress.LastSyncSource.Valid { @@ -279,7 +279,7 @@ templ BookDetail(user User, book handlers.MediaDetail, errorMessage string) { if book.DatePublished.Valid {

Published

-

{ book.DatePublished.Time.Format("2006-01-02") }

+

{ book.DatePublished.Time.Format("01-02-2006") }

} if book.Isbn.Valid && book.Isbn.String != "" { diff --git a/templates/book_detail_modals.templ b/templates/book_detail_modals.templ index 146f0d3..288a41b 100644 --- a/templates/book_detail_modals.templ +++ b/templates/book_detail_modals.templ @@ -65,7 +65,7 @@ templ ProgressSyncModal(book handlers.MediaDetail) { { source }

- { data.Timestamp.Format("2006-01-02 15:04:05") } + { data.Timestamp.Format("01-02-2006 03:04 PM:05") }

@@ -110,7 +110,7 @@ templ ProgressSyncModal(book handlers.MediaDetail) { } if book.ReadingProgress.LastReadAt.Valid {

- Last read: { book.ReadingProgress.LastReadAt.Time.Format("2006-01-02 15:04") } + Last read: { book.ReadingProgress.LastReadAt.Time.Format("01-02-2006 03:04 PM") }

}
diff --git a/templates/book_detail_modals_templ.go b/templates/book_detail_modals_templ.go index 5ebd8ce..b7fcdb8 100644 --- a/templates/book_detail_modals_templ.go +++ b/templates/book_detail_modals_templ.go @@ -76,9 +76,9 @@ func ProgressSyncModal(book handlers.MediaDetail) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var4 string - templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(data.Timestamp.Format("2006-01-02 15:04:05")) + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(data.Timestamp.Format("01-02-2006 03:04 PM:05")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/book_detail_modals.templ`, Line: 68, Col: 56} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/book_detail_modals.templ`, Line: 68, Col: 59} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -243,9 +243,9 @@ func ProgressSyncModal(book handlers.MediaDetail) templ.Component { return templ_7745c5c3_Err } var templ_7745c5c3_Var14 string - templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(book.ReadingProgress.LastReadAt.Time.Format("2006-01-02 15:04")) + templ_7745c5c3_Var14, templ_7745c5c3_Err = templ.JoinStringErrs(book.ReadingProgress.LastReadAt.Time.Format("01-02-2006 03:04 PM")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/book_detail_modals.templ`, Line: 113, Col: 83} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/book_detail_modals.templ`, Line: 113, Col: 86} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14)) if templ_7745c5c3_Err != nil { diff --git a/templates/book_detail_templ.go b/templates/book_detail_templ.go index 33a9593..daa8e56 100644 --- a/templates/book_detail_templ.go +++ b/templates/book_detail_templ.go @@ -438,7 +438,7 @@ func BookDetail(user User, book handlers.MediaDetail, errorMessage string) templ var templ_7745c5c3_Var17 string templ_7745c5c3_Var17, templ_7745c5c3_Err = templruntime.SanitizeStyleAttributeValues(fmt.Sprintf("width: %.1f%%; background-color: var(--accent);", book.ReadingProgress.Percentage.Float64*100)) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/book_detail.templ`, Line: 232, Col: 126} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/book_detail.templ`, Line: 232, Col: 124} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17)) if templ_7745c5c3_Err != nil { @@ -499,9 +499,9 @@ func BookDetail(user User, book handlers.MediaDetail, errorMessage string) templ return templ_7745c5c3_Err } var templ_7745c5c3_Var21 string - templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(book.ReadingProgress.LastReadAt.Time.Format("2006-01-02 15:04")) + templ_7745c5c3_Var21, templ_7745c5c3_Err = templ.JoinStringErrs(book.ReadingProgress.LastReadAt.Time.Format("01-02-2006 03:04 PM")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/book_detail.templ`, Line: 253, Col: 77} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/book_detail.templ`, Line: 253, Col: 80} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21)) if templ_7745c5c3_Err != nil { @@ -565,7 +565,7 @@ func BookDetail(user User, book handlers.MediaDetail, errorMessage string) templ return templ_7745c5c3_Err } var templ_7745c5c3_Var24 string - templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(book.DatePublished.Time.Format("2006-01-02")) + templ_7745c5c3_Var24, templ_7745c5c3_Err = templ.JoinStringErrs(book.DatePublished.Time.Format("01-02-2006")) if templ_7745c5c3_Err != nil { return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/book_detail.templ`, Line: 282, Col: 57} } diff --git a/templates/conflicts.templ b/templates/conflicts.templ index 21d9b19..d8bb326 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("2006-01-02 15:04:05") } + Created: { conflict.CreatedAt.Format("01-02-2006 03:04:05 PM") } if conflict.ResolvedBy != "" { | Resolved by: { conflict.ResolvedBy } } diff --git a/templates/conflicts_templ.go b/templates/conflicts_templ.go index e35c693..5a248bb 100644 --- a/templates/conflicts_templ.go +++ b/templates/conflicts_templ.go @@ -120,9 +120,9 @@ func Conflicts(user User, conflicts []handlers.ConflictDetailResponse, total int return templ_7745c5c3_Err } var templ_7745c5c3_Var7 string - templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(conflict.CreatedAt.Format("2006-01-02 15:04:05")) + templ_7745c5c3_Var7, templ_7745c5c3_Err = templ.JoinStringErrs(conflict.CreatedAt.Format("01-02-2006 03:04:05 PM")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/conflicts.templ`, Line: 114, Col: 67} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/conflicts.templ`, Line: 114, Col: 70} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7)) if templ_7745c5c3_Err != nil { diff --git a/templates/devices.templ b/templates/devices.templ index 5dc96c2..2f8141e 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("2006-01-02 15:04") } + { device.LastSync.Format("01-02-2006 03:04 PM") } } else { Never } @@ -88,7 +88,7 @@ templ Devices(user User, devices []handlers.DeviceInfo, pendingRegistrations []P
Last Seen if device.LastSeen != nil { - { device.LastSeen.Format("2006-01-02 15:04") } + { device.LastSeen.Format("01-02-2006 03:04 PM") } } else { Never } diff --git a/templates/devices_templ.go b/templates/devices_templ.go index 69188de..2b4d0b8 100644 --- a/templates/devices_templ.go +++ b/templates/devices_templ.go @@ -135,9 +135,9 @@ func Devices(user User, devices []handlers.DeviceInfo, pendingRegistrations []Pe return templ_7745c5c3_Err } var templ_7745c5c3_Var4 string - templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(device.LastSync.Format("2006-01-02 15:04")) + templ_7745c5c3_Var4, templ_7745c5c3_Err = templ.JoinStringErrs(device.LastSync.Format("01-02-2006 03:04 PM")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/devices.templ`, Line: 83, Col: 97} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/devices.templ`, Line: 83, Col: 100} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4)) if templ_7745c5c3_Err != nil { @@ -163,9 +163,9 @@ func Devices(user User, devices []handlers.DeviceInfo, pendingRegistrations []Pe return templ_7745c5c3_Err } var templ_7745c5c3_Var5 string - templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(device.LastSeen.Format("2006-01-02 15:04")) + templ_7745c5c3_Var5, templ_7745c5c3_Err = templ.JoinStringErrs(device.LastSeen.Format("01-02-2006 03:04 PM")) if templ_7745c5c3_Err != nil { - return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/devices.templ`, Line: 91, Col: 97} + return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/devices.templ`, Line: 91, Col: 100} } _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5)) if templ_7745c5c3_Err != nil {