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/models/timeline.go | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'internal/models/timeline.go') diff --git a/internal/models/timeline.go b/internal/models/timeline.go index 54f7f45..3475696 100644 --- a/internal/models/timeline.go +++ b/internal/models/timeline.go @@ -1,6 +1,10 @@ package models -import "time" +import ( + "time" + + "task-dashboard/internal/config" +) type TimelineItemType string @@ -37,15 +41,16 @@ type TimelineItem struct { // ComputeDaySection sets the DaySection based on the item's time func (item *TimelineItem) ComputeDaySection(now time.Time) { - // Ensure we're working in local timezone for consistent comparisons - localNow := now.Local() - localItemTime := item.Time.Local() + // Use configured display timezone for consistent comparisons + tz := config.GetDisplayTimezone() + localNow := now.In(tz) + localItemTime := item.Time.In(tz) - today := time.Date(localNow.Year(), localNow.Month(), localNow.Day(), 0, 0, 0, 0, time.Local) + today := time.Date(localNow.Year(), localNow.Month(), localNow.Day(), 0, 0, 0, 0, tz) tomorrow := today.AddDate(0, 0, 1) dayAfterTomorrow := today.AddDate(0, 0, 2) - itemDay := time.Date(localItemTime.Year(), localItemTime.Month(), localItemTime.Day(), 0, 0, 0, 0, time.Local) + itemDay := time.Date(localItemTime.Year(), localItemTime.Month(), localItemTime.Day(), 0, 0, 0, 0, tz) if itemDay.Before(tomorrow) { item.DaySection = DaySectionToday -- cgit v1.2.3