Skip to content

Commit

Permalink
Fixed bug #6
Browse files Browse the repository at this point in the history
  • Loading branch information
d4r1us-drk committed Aug 12, 2024
1 parent 2fd349a commit 20de811
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion pkg/utils/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,15 +67,34 @@ func FormatDate(t *time.Time) string {
return t.Format("2006-01-02 15:04")
}


func ColoredPastDue(dueDate *time.Time, completed bool) string {
if dueDate == nil {
return color.GreenString("no")
}
if dueDate.Before(time.Now()) {

// Ensure the current time is in the local time zone
now := time.Now()
localLocation := now.Location()

// Grab dueDate and interpret it as local time
dueDateAsLocalTime := time.Date(
dueDate.Year(),
dueDate.Month(),
dueDate.Day(),
dueDate.Hour(),
dueDate.Minute(),
dueDate.Second(),
dueDate.Nanosecond(),
localLocation, // Use local timezone for interpretation
)

if now.After(dueDateAsLocalTime) {
if completed {
return color.GreenString("yes")
}
return color.RedString("yes")
}

return color.GreenString("no")
}

0 comments on commit 20de811

Please sign in to comment.