aboutsummaryrefslogtreecommitdiffstats
path: root/todolist/util.go
diff options
context:
space:
mode:
authorGrant Ammons <gammons@gmail.com>2017-03-07 08:12:35 -0500
committerGrant Ammons <gammons@gmail.com>2017-03-07 08:12:35 -0500
commit5763376a7ef50a116f9585ffd280bbf8e37621d3 (patch)
tree8dc6d5376e1bf422a1aa693c27f505721741a1f0 /todolist/util.go
parent871fb90b26a98ee3569c325940a5f4e380631c54 (diff)
parent34931b46ed9ebb06e9555d6e62c98c70dc460d59 (diff)
Merge branch 'master' into garbage-collect
Diffstat (limited to 'todolist/util.go')
-rw-r--r--todolist/util.go17
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
+ }
+ }
+}