diff options
Diffstat (limited to 'internal/models')
| -rw-r--r-- | internal/models/atom.go | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/internal/models/atom.go b/internal/models/atom.go index fe40962..b3a384a 100644 --- a/internal/models/atom.go +++ b/internal/models/atom.go @@ -36,11 +36,30 @@ type Atom struct { // UI Helpers (to be populated by mappers) SourceIcon string // e.g., "trello-icon.svg" or emoji ColorClass string // e.g., "border-blue-500" + IsOverdue bool // True if due date is before today + HasSetTime bool // True if due time is not midnight (has specific time) // Original Data (for write operations) Raw interface{} } +// ComputeUIFields calculates IsOverdue and HasSetTime based on DueDate +func (a *Atom) ComputeUIFields() { + if a.DueDate == nil { + return + } + + now := time.Now() + today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, now.Location()) + + // 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()) + a.IsOverdue = dueDay.Before(today) + + // Check if has set time (not midnight) + a.HasSetTime = a.DueDate.Hour() != 0 || a.DueDate.Minute() != 0 +} + // TaskToAtom converts a Todoist Task to an Atom func TaskToAtom(t Task) Atom { // Todoist priority: 1 (normal) to 4 (urgent) @@ -63,7 +82,7 @@ func TaskToAtom(t Task) Atom { DueDate: t.DueDate, CreatedAt: t.CreatedAt, Priority: priority, - SourceIcon: "✓", // Checkmark emoji for tasks + SourceIcon: "🔴", // Red circle for Todoist ColorClass: "border-red-500", Raw: t, } |
