diff options
| author | Peter Stone <thepeterstone@gmail.com> | 2026-01-26 16:49:44 -1000 |
|---|---|---|
| committer | Peter Stone <thepeterstone@gmail.com> | 2026-01-26 16:49:44 -1000 |
| commit | 42a4e32daca13b518e64e5821080ff3d6adf0e39 (patch) | |
| tree | 639c790e25b961ecf51ab6ea75206bc3432f1548 /internal/models/atom.go | |
| parent | 8de1b5cb8915ed9a6e32566431d05fafafeb338d (diff) | |
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 <noreply@anthropic.com>
Diffstat (limited to 'internal/models/atom.go')
| -rw-r--r-- | internal/models/atom.go | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/internal/models/atom.go b/internal/models/atom.go index 3e08896..3804de4 100644 --- a/internal/models/atom.go +++ b/internal/models/atom.go @@ -3,6 +3,8 @@ package models import ( "fmt" "time" + + "task-dashboard/internal/config" ) type AtomSource string @@ -56,19 +58,21 @@ func (a *Atom) ComputeUIFields() { return } - now := time.Now() - today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()) + tz := config.GetDisplayTimezone() + now := config.Now() + today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, tz) tomorrow := today.AddDate(0, 0, 1) // Check if overdue (due date is before today) - dueDay := time.Date(a.DueDate.Year(), a.DueDate.Month(), a.DueDate.Day(), 0, 0, 0, 0, a.DueDate.Location()) + dueInTZ := a.DueDate.In(tz) + dueDay := time.Date(dueInTZ.Year(), dueInTZ.Month(), dueInTZ.Day(), 0, 0, 0, 0, tz) a.IsOverdue = dueDay.Before(today) // Check if future (due date is after today) a.IsFuture = !dueDay.Before(tomorrow) // Check if has set time (not midnight) - a.HasSetTime = a.DueDate.Hour() != 0 || a.DueDate.Minute() != 0 + a.HasSetTime = dueInTZ.Hour() != 0 || dueInTZ.Minute() != 0 } // TaskToAtom converts a Todoist Task to an Atom |
