diff options
| author | Grant Ammons <gammons@gmail.com> | 2017-03-07 08:11:13 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-03-07 08:11:13 -0500 |
| commit | 34931b46ed9ebb06e9555d6e62c98c70dc460d59 (patch) | |
| tree | 7abefe0115f24ea94a007827a8e8239198b3e585 /todolist/util.go | |
| parent | 7e50f18e5ed99abb58d3235b0060fc11ba9aa83d (diff) | |
| parent | ee5353cf832a2fec57eacb77396a443e6d6a5b9e (diff) | |
Merge pull request #35 from DmitriyMV/fix/time
Remove github.com/jinzhu/now.
Diffstat (limited to 'todolist/util.go')
| -rw-r--r-- | todolist/util.go | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/todolist/util.go b/todolist/util.go index bbed216..72d475f 100644 --- a/todolist/util.go +++ b/todolist/util.go @@ -1,5 +1,7 @@ package todolist +import "time" + func AddIfNotThere(arr []string, items []string) []string { for _, item := range items { there := false @@ -27,3 +29,18 @@ func AddTodoIfNotThere(arr []*Todo, item *Todo) []*Todo { } return arr } + +func bod(t time.Time) time.Time { + year, month, day := t.Date() + return time.Date(year, month, day, 0, 0, 0, 0, t.Location()) +} + +func getNearestMonday(t time.Time) time.Time { + for { + if t.Weekday() != time.Monday { + t = t.AddDate(0, 0, -1) + } else { + return t + } + } +} |
