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
This commit is contained in:
2026-04-27 21:31:19 -04:00
parent 3b5af3beae
commit 17281e4ce7
12 changed files with 33 additions and 33 deletions
+8 -8
View File
@@ -75,18 +75,18 @@ func (h *AnalyticsHandler) GetReadingStats(c *echo.Context) error {
endDate := c.QueryParam("end_date") endDate := c.QueryParam("end_date")
if startDate == "" { 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 == "" { 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 { if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "invalid start_date format") 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 { if err != nil {
return echo.NewHTTPError(http.StatusBadRequest, "invalid end_date format") return echo.NewHTTPError(http.StatusBadRequest, "invalid end_date format")
} }
@@ -130,7 +130,7 @@ func (h *AnalyticsHandler) calculateReadingStats(history []database.GetUserReadi
longestSession = int(minutes) longestSession = int(minutes)
} }
dateKey := entry.CreatedAt.Time.Format("2006-01-02") dateKey := entry.CreatedAt.Time.Format("01-02-2006")
if dailyMap[dateKey] == nil { if dailyMap[dateKey] == nil {
dailyMap[dateKey] = &DailyReading{ dailyMap[dateKey] = &DailyReading{
Date: dateKey, Date: dateKey,
@@ -141,7 +141,7 @@ func (h *AnalyticsHandler) calculateReadingStats(history []database.GetUserReadi
if entry.PagesRead.Valid { if entry.PagesRead.Valid {
totalPages += int(entry.PagesRead.Int32) 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 { if dailyMap[dateKey] != nil {
dailyMap[dateKey].Pages += int(entry.PagesRead.Int32) dailyMap[dateKey].Pages += int(entry.PagesRead.Int32)
} }
@@ -222,7 +222,7 @@ func (h *AnalyticsHandler) GetDeviceUsage(c *echo.Context) error {
lastSync := "" lastSync := ""
if u.LastSync != nil { if u.LastSync != nil {
if t, ok := u.LastSync.(time.Time); ok { 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 := "" lastRead := ""
if book.LastRead != nil { if book.LastRead != nil {
if t, ok := book.LastRead.(time.Time); ok { 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")
} }
} }
+1 -1
View File
@@ -306,7 +306,7 @@ func (h *Handler) GetAllProgress(c *echo.Context) error {
lastUpdated := "" lastUpdated := ""
if progress.LastReadAt.Valid { 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{ progressList = append(progressList, ProgressWithMedia{
+1 -1
View File
@@ -86,7 +86,7 @@ templ AdminUsers(currentUser User, users []User, adminCount int) {
</td> </td>
<!-- Created --> <!-- Created -->
<td class="px-6 py-4 whitespace-nowrap"> <td class="px-6 py-4 whitespace-nowrap">
<div class="text-sm" style="color: var(--text-secondary)">{ user.CreatedAt.Format("2006-01-02") }</div> <div class="text-sm" style="color: var(--text-secondary)">{ user.CreatedAt.Format("01-02-2006") }</div>
</td> </td>
<!-- Actions --> <!-- Actions -->
<td class="px-6 py-4 whitespace-nowrap text-right"> <td class="px-6 py-4 whitespace-nowrap text-right">
+1 -1
View File
@@ -178,7 +178,7 @@ func AdminUsers(currentUser User, users []User, adminCount int) templ.Component
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var8 string 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 { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/admin_users.templ`, Line: 89, Col: 106} return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/admin_users.templ`, Line: 89, Col: 106}
} }
+3 -3
View File
@@ -229,7 +229,7 @@ templ BookDetail(user User, book handlers.MediaDetail, errorMessage string) {
<div class="w-full rounded-full h-3" style="background-color: var(--bg-primary);"> <div class="w-full rounded-full h-3" style="background-color: var(--bg-primary);">
<div <div
class="h-3 rounded-full transition-all" class="h-3 rounded-full transition-all"
style={ fmt.Sprintf("width: %.1f%%; background-color: var(--accent);", book.ReadingProgress.Percentage.Float64 * 100) } style={ fmt.Sprintf("width: %.1f%%; background-color: var(--accent);", book.ReadingProgress.Percentage.Float64*100) }
></div> ></div>
</div> </div>
</div> </div>
@@ -250,7 +250,7 @@ templ BookDetail(user User, book handlers.MediaDetail, errorMessage string) {
if book.ReadingProgress.LastReadAt.Valid { if book.ReadingProgress.LastReadAt.Valid {
<div> <div>
<p style="color: var(--text-secondary)">Last Read</p> <p style="color: var(--text-secondary)">Last Read</p>
<p>{ book.ReadingProgress.LastReadAt.Time.Format("2006-01-02 15:04") }</p> <p>{ book.ReadingProgress.LastReadAt.Time.Format("01-02-2006 03:04 PM") }</p>
</div> </div>
} }
if book.ReadingProgress.LastSyncSource.Valid { if book.ReadingProgress.LastSyncSource.Valid {
@@ -279,7 +279,7 @@ templ BookDetail(user User, book handlers.MediaDetail, errorMessage string) {
if book.DatePublished.Valid { if book.DatePublished.Valid {
<div> <div>
<p style="color: var(--text-secondary)">Published</p> <p style="color: var(--text-secondary)">Published</p>
<p>{ book.DatePublished.Time.Format("2006-01-02") }</p> <p>{ book.DatePublished.Time.Format("01-02-2006") }</p>
</div> </div>
} }
if book.Isbn.Valid && book.Isbn.String != "" { if book.Isbn.Valid && book.Isbn.String != "" {
+2 -2
View File
@@ -65,7 +65,7 @@ templ ProgressSyncModal(book handlers.MediaDetail) {
{ source } { source }
</span> </span>
<p class="text-xs" style="color: var(--text-secondary);"> <p class="text-xs" style="color: var(--text-secondary);">
{ data.Timestamp.Format("2006-01-02 15:04:05") } { data.Timestamp.Format("01-02-2006 03:04 PM:05") }
</p> </p>
</div> </div>
<div class="text-right"> <div class="text-right">
@@ -110,7 +110,7 @@ templ ProgressSyncModal(book handlers.MediaDetail) {
} }
if book.ReadingProgress.LastReadAt.Valid { if book.ReadingProgress.LastReadAt.Valid {
<p class="text-sm mt-2" style="color: var(--text-secondary);"> <p class="text-sm mt-2" style="color: var(--text-secondary);">
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") }
</p> </p>
} }
</div> </div>
+4 -4
View File
@@ -76,9 +76,9 @@ func ProgressSyncModal(book handlers.MediaDetail) templ.Component {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var4 string 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 { 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)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@@ -243,9 +243,9 @@ func ProgressSyncModal(book handlers.MediaDetail) templ.Component {
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var14 string 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 { 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)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var14))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
+4 -4
View File
@@ -438,7 +438,7 @@ func BookDetail(user User, book handlers.MediaDetail, errorMessage string) templ
var templ_7745c5c3_Var17 string 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)) 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 { 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)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var17))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@@ -499,9 +499,9 @@ func BookDetail(user User, book handlers.MediaDetail, errorMessage string) templ
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var21 string 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 { 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)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var21))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@@ -565,7 +565,7 @@ func BookDetail(user User, book handlers.MediaDetail, errorMessage string) templ
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var24 string 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 { if templ_7745c5c3_Err != nil {
return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/book_detail.templ`, Line: 282, Col: 57} return templ.Error{Err: templ_7745c5c3_Err, FileName: `templates/book_detail.templ`, Line: 282, Col: 57}
} }
+1 -1
View File
@@ -111,7 +111,7 @@ templ Conflicts(user User, conflicts []handlers.ConflictDetailResponse, total in
</button> </button>
</div> </div>
<div class="text-sm" style="color: var(--text-secondary)"> <div class="text-sm" style="color: var(--text-secondary)">
Created: { conflict.CreatedAt.Format("2006-01-02 15:04:05") } Created: { conflict.CreatedAt.Format("01-02-2006 03:04:05 PM") }
if conflict.ResolvedBy != "" { if conflict.ResolvedBy != "" {
| Resolved by: { conflict.ResolvedBy } | Resolved by: { conflict.ResolvedBy }
} }
+2 -2
View File
@@ -120,9 +120,9 @@ func Conflicts(user User, conflicts []handlers.ConflictDetailResponse, total int
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var7 string 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 { 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)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var7))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
+2 -2
View File
@@ -80,7 +80,7 @@ templ Devices(user User, devices []handlers.DeviceInfo, pendingRegistrations []P
<div class="flex justify-between"> <div class="flex justify-between">
<span style="color: var(--text-secondary)">Last Sync</span> <span style="color: var(--text-secondary)">Last Sync</span>
if device.LastSync != nil { if device.LastSync != nil {
<span style="color: var(--text-primary)">{ device.LastSync.Format("2006-01-02 15:04") }</span> <span style="color: var(--text-primary)">{ device.LastSync.Format("01-02-2006 03:04 PM") }</span>
} else { } else {
<span style="color: var(--text-primary)">Never</span> <span style="color: var(--text-primary)">Never</span>
} }
@@ -88,7 +88,7 @@ templ Devices(user User, devices []handlers.DeviceInfo, pendingRegistrations []P
<div class="flex justify-between"> <div class="flex justify-between">
<span style="color: var(--text-secondary)">Last Seen</span> <span style="color: var(--text-secondary)">Last Seen</span>
if device.LastSeen != nil { if device.LastSeen != nil {
<span style="color: var(--text-primary)">{ device.LastSeen.Format("2006-01-02 15:04") }</span> <span style="color: var(--text-primary)">{ device.LastSeen.Format("01-02-2006 03:04 PM") }</span>
} else { } else {
<span style="color: var(--text-primary)">Never</span> <span style="color: var(--text-primary)">Never</span>
} }
+4 -4
View File
@@ -135,9 +135,9 @@ func Devices(user User, devices []handlers.DeviceInfo, pendingRegistrations []Pe
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var4 string 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 { 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)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var4))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {
@@ -163,9 +163,9 @@ func Devices(user User, devices []handlers.DeviceInfo, pendingRegistrations []Pe
return templ_7745c5c3_Err return templ_7745c5c3_Err
} }
var templ_7745c5c3_Var5 string 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 { 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)) _, templ_7745c5c3_Err = templ_7745c5c3_Buffer.WriteString(templ.EscapeString(templ_7745c5c3_Var5))
if templ_7745c5c3_Err != nil { if templ_7745c5c3_Err != nil {