diff options
Diffstat (limited to 'internal/ui/helpers.go')
| -rw-r--r-- | internal/ui/helpers.go | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/internal/ui/helpers.go b/internal/ui/helpers.go index 89e771a..0358e86 100644 --- a/internal/ui/helpers.go +++ b/internal/ui/helpers.go @@ -26,10 +26,14 @@ func parseTaskDate(dateStr string) (time.Time, error) { // daysUntil returns the number of days until the given time func daysUntil(t time.Time) int { - now := time.Now() - // Normalize both times to midnight UTC to avoid timezone and fractional day issues + now := time.Now().In(time.Local) + targetLocal := t.In(time.Local) + + // Taskwarrior exports date-only due values as the local midnight instant in + // UTC. Compare local calendar dates, then use UTC midnights for stable + // whole-day arithmetic across DST transitions. today := time.Date(now.Year(), now.Month(), now.Day(), 0, 0, 0, 0, time.UTC) - target := time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, time.UTC) + target := time.Date(targetLocal.Year(), targetLocal.Month(), targetLocal.Day(), 0, 0, 0, 0, time.UTC) return int(target.Sub(today) / (24 * time.Hour)) } |
