package models import ( "time" "task-dashboard/internal/config" ) type TimelineItemType string const ( TimelineItemTypeTask TimelineItemType = "task" TimelineItemTypeMeal TimelineItemType = "meal" TimelineItemTypeCard TimelineItemType = "card" TimelineItemTypeEvent TimelineItemType = "event" TimelineItemTypeGTask TimelineItemType = "gtask" // Google Tasks ) type DaySection string const ( DaySectionToday DaySection = "today" DaySectionTomorrow DaySection = "tomorrow" DaySectionLater DaySection = "later" ) type TimelineItem struct { ID string `json:"id"` Type TimelineItemType `json:"type"` Title string `json:"title"` Time time.Time `json:"time"` EndTime *time.Time `json:"end_time,omitempty"` 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", "gtasks" // Source-specific metadata ListID string `json:"list_id,omitempty"` // For Google Tasks } // ComputeDaySection sets the DaySection based on the item's time func (item *TimelineItem) ComputeDaySection(now time.Time) { // 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, 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, tz) if itemDay.Before(tomorrow) { item.DaySection = DaySectionToday } else if itemDay.Before(dayAfterTomorrow) { item.DaySection = DaySectionTomorrow } else { item.DaySection = DaySectionLater } }