From 76008647c8c1611f65315ad40a4f164f51bcbb2f Mon Sep 17 00:00:00 2001 From: Bel LaPointe Date: Fri, 31 Dec 2021 16:16:38 -0500 Subject: [PATCH] add todo.triggered to indicate should be set to todo --- pttodo/todo.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pttodo/todo.go b/pttodo/todo.go index 9eb3f57..bede663 100644 --- a/pttodo/todo.go +++ b/pttodo/todo.go @@ -1,8 +1,16 @@ package pttodo +import "time" + type Todo struct { Todo string Detail string `yaml:",omitempty"` TS TS `yaml:",omitempty"` Schedule Schedule `yaml:",omitempty"` } + +func (todo Todo) Triggered() bool { + last := todo.TS + next, err := todo.Schedule.Next(last.time()) + return err == nil && time.Now().After(next) +}