diff options
| author | Grant Ammons <gammons@gmail.com> | 2017-10-04 07:34:43 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-10-04 07:34:43 -0400 |
| commit | b3bd13d469ff1c072e5ff6dfe15267cc51e14db5 (patch) | |
| tree | 49bfa1d32b280be32ac42f1d0ddf1ef07f6809fe /todolist/util.go | |
| parent | 0840e7a147d8594acec63fd1ce8aba9e15472839 (diff) | |
| parent | 6193b27cd7c71bcff5b5dd0cafb4f04172a73206 (diff) | |
Merge pull request #109 from gammons/refactor-printer
Refactor the formatter to an interface and rename it
Diffstat (limited to 'todolist/util.go')
| -rw-r--r-- | todolist/util.go | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/todolist/util.go b/todolist/util.go index ff3dbba..6fa93f3 100644 --- a/todolist/util.go +++ b/todolist/util.go @@ -59,3 +59,23 @@ func pluralize(count int, singular, plural string) string { } return singular } + +func isToday(t time.Time) bool { + nowYear, nowMonth, nowDay := time.Now().Date() + timeYear, timeMonth, timeDay := t.Date() + return nowYear == timeYear && + nowMonth == timeMonth && + nowDay == timeDay +} + +func isTomorrow(t time.Time) bool { + nowYear, nowMonth, nowDay := time.Now().AddDate(0, 0, 1).Date() + timeYear, timeMonth, timeDay := t.Date() + return nowYear == timeYear && + nowMonth == timeMonth && + nowDay == timeDay +} + +func isPastDue(t time.Time) bool { + return time.Now().After(t) +} |
