diff options
Diffstat (limited to 'internal/models/timeline.go')
| -rw-r--r-- | internal/models/timeline.go | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/internal/models/timeline.go b/internal/models/timeline.go index 4a619fa..469cce4 100644 --- a/internal/models/timeline.go +++ b/internal/models/timeline.go @@ -11,6 +11,14 @@ const ( TimelineItemTypeEvent TimelineItemType = "event" ) +type DaySection string + +const ( + DaySectionToday DaySection = "today" + DaySectionTomorrow DaySection = "tomorrow" + DaySectionLater DaySection = "later" +) + type TimelineItem struct { ID string `json:"id"` Type TimelineItemType `json:"type"` @@ -20,4 +28,26 @@ type TimelineItem struct { Description string `json:"description,omitempty"` URL string `json:"url,omitempty"` OriginalItem interface{} `json:"-"` + + // UI enhancement fields + IsCompleted bool `json:"is_completed"` + DaySection DaySection `json:"day_section"` + Source string `json:"source"` // "todoist", "trello", "plantoeat", "calendar" +} + +// ComputeDaySection sets the DaySection based on the item's time +func (item *TimelineItem) ComputeDaySection(now time.Time) { + today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()) + tomorrow := today.AddDate(0, 0, 1) + dayAfterTomorrow := today.AddDate(0, 0, 2) + + itemDay := time.Date(item.Time.Year(), item.Time.Month(), item.Time.Day(), 0, 0, 0, 0, item.Time.Location()) + + if itemDay.Before(tomorrow) { + item.DaySection = DaySectionToday + } else if itemDay.Before(dayAfterTomorrow) { + item.DaySection = DaySectionTomorrow + } else { + item.DaySection = DaySectionLater + } } |
