diff options
Diffstat (limited to 'internal/models')
| -rw-r--r-- | internal/models/atom.go | 6 | ||||
| -rw-r--r-- | internal/models/atom_test.go | 34 |
2 files changed, 37 insertions, 3 deletions
diff --git a/internal/models/atom.go b/internal/models/atom.go index 9c519ba..3745917 100644 --- a/internal/models/atom.go +++ b/internal/models/atom.go @@ -57,15 +57,15 @@ func (a *Atom) ComputeUIFields() { 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) 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 future (due date is 7+ days out — collapse in tasks tab) + sevenDaysOut := today.AddDate(0, 0, 7) + a.IsFuture = !dueDay.Before(sevenDaysOut) // Check if has set time (not midnight) a.HasSetTime = dueInTZ.Hour() != 0 || dueInTZ.Minute() != 0 diff --git a/internal/models/atom_test.go b/internal/models/atom_test.go index 3ed4774..70bc14b 100644 --- a/internal/models/atom_test.go +++ b/internal/models/atom_test.go @@ -134,6 +134,40 @@ func TestAtom_ComputeUIFields(t *testing.T) { } }) + // Tasks due within 7 days should NOT be IsFuture (shown in main section with dates) + t.Run("tomorrow is not future", func(t *testing.T) { + tz := time.UTC + now := time.Now().In(tz) + tomorrow := time.Date(now.Year(), now.Month(), now.Day()+1, 0, 0, 0, 0, tz) + atom := Atom{DueDate: &tomorrow} + atom.ComputeUIFields() + if atom.IsFuture { + t.Error("Task due tomorrow should not be IsFuture — it should appear in main tasks section with its date visible") + } + }) + + t.Run("6 days out is not future", func(t *testing.T) { + tz := time.UTC + now := time.Now().In(tz) + sixDays := time.Date(now.Year(), now.Month(), now.Day()+6, 0, 0, 0, 0, tz) + atom := Atom{DueDate: &sixDays} + atom.ComputeUIFields() + if atom.IsFuture { + t.Error("Task due in 6 days should not be IsFuture") + } + }) + + t.Run("8 days out is future", func(t *testing.T) { + tz := time.UTC + now := time.Now().In(tz) + eightDays := time.Date(now.Year(), now.Month(), now.Day()+8, 0, 0, 0, 0, tz) + atom := Atom{DueDate: &eightDays} + atom.ComputeUIFields() + if !atom.IsFuture { + t.Error("Task due in 8 days should be IsFuture") + } + }) + // Test with due date at midnight (no specific time) t.Run("midnight due date", func(t *testing.T) { now := time.Now() |
