diff options
Diffstat (limited to 'internal/models')
| -rw-r--r-- | internal/models/atom.go | 12 | ||||
| -rw-r--r-- | internal/models/timeline.go | 17 |
2 files changed, 19 insertions, 10 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 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 |
