add todo.ID()
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package pttodo
|
||||
|
||||
import (
|
||||
"encoding/base64"
|
||||
"fmt"
|
||||
"hash/crc32"
|
||||
"time"
|
||||
)
|
||||
|
||||
@@ -15,6 +17,18 @@ type Todo struct {
|
||||
writeTS bool
|
||||
}
|
||||
|
||||
func (todo Todo) ID() string {
|
||||
hash := crc32.NewIEEE()
|
||||
fmt.Fprintf(hash, "%d:%s", 0, todo.Todo)
|
||||
fmt.Fprintf(hash, "%d:%s", 1, todo.Details)
|
||||
fmt.Fprintf(hash, "%d:%s", 2, todo.Schedule)
|
||||
fmt.Fprintf(hash, "%d:%s", 3, todo.Tags)
|
||||
for i := range todo.Subtasks {
|
||||
fmt.Fprintf(hash, "%d:%s", 4, todo.Subtasks[i].ID())
|
||||
}
|
||||
return base64.StdEncoding.EncodeToString(hash.Sum(nil))
|
||||
}
|
||||
|
||||
func (todo Todo) Triggered() bool {
|
||||
last := todo.TS
|
||||
next, err := todo.Schedule.Next(last.time())
|
||||
|
||||
Reference in New Issue
Block a user