only write TS on a todo if writeTS is set

master
Bel LaPointe 2022-01-02 20:37:40 -05:00
parent 8002b5e75c
commit fdb24fcc60
1 changed files with 7 additions and 1 deletions

View File

@ -7,11 +7,12 @@ import (
type Todo struct {
Todo string
TS TS
Details string `yaml:",omitempty"`
Schedule Schedule `yaml:",omitempty"`
Tags string `yaml:",omitempty"`
Subtasks []Todo `yaml:",omitempty"`
TS TS `yaml:",omitempty"`
writeTS bool
}
func (todo Todo) Triggered() bool {
@ -21,6 +22,11 @@ func (todo Todo) Triggered() bool {
}
func (todo Todo) MarshalYAML() (interface{}, error) {
if !todo.writeTS {
todo.TS = 0
} else {
todo.TS = TS(todo.TS.time().Unix())
}
if fmt.Sprint(todo) == fmt.Sprint(Todo{Todo: todo.Todo}) {
return todo.Todo, nil
}