From 42a4e32daca13b518e64e5821080ff3d6adf0e39 Mon Sep 17 00:00:00 2001 From: Peter Stone Date: Mon, 26 Jan 2026 16:49:44 -1000 Subject: Use configured timezone throughout codebase - Add config/timezone.go with timezone utilities: - SetDisplayTimezone(), GetDisplayTimezone() - Now(), Today() - current time/date in display TZ - ParseDateInDisplayTZ(), ToDisplayTZ() - parsing helpers - Initialize timezone at startup in main.go - Update all datetime logic to use configured timezone: - handlers/handlers.go - all time.Now() calls - handlers/timeline.go - date parsing - handlers/timeline_logic.go - now calculation - models/atom.go - ComputeUIFields() - models/timeline.go - ComputeDaySection() - api/plantoeat.go - meal date parsing - api/todoist.go - due date parsing - api/trello.go - due date parsing This ensures all dates/times display correctly regardless of server timezone setting. Co-Authored-By: Claude Opus 4.5 --- internal/handlers/timeline.go | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'internal/handlers/timeline.go') diff --git a/internal/handlers/timeline.go b/internal/handlers/timeline.go index ce0e831..9821452 100644 --- a/internal/handlers/timeline.go +++ b/internal/handlers/timeline.go @@ -5,6 +5,7 @@ import ( "strconv" "time" + "task-dashboard/internal/config" "task-dashboard/internal/models" ) @@ -25,19 +26,16 @@ func (h *Handler) HandleTimeline(w http.ResponseWriter, r *http.Request) { var start time.Time if startStr != "" { - parsed, err := time.ParseInLocation("2006-01-02", startStr, time.Local) + parsed, err := config.ParseDateInDisplayTZ(startStr) if err == nil { start = parsed } else { - start = time.Now() + start = config.Today() } } else { - start = time.Now() + start = config.Today() } - // Normalize start to beginning of day - start = time.Date(start.Year(), start.Month(), start.Day(), 0, 0, 0, 0, start.Location()) - days := 3 // Default if daysStr != "" { if d, err := strconv.Atoi(daysStr); err == nil && d > 0 { -- cgit v1.2.3