49 lines
813 B
Go
49 lines
813 B
Go
package main
|
|
|
|
import (
|
|
_ "embed"
|
|
"fmt"
|
|
"time"
|
|
)
|
|
|
|
//go:embed todo.txt
|
|
var todotxt []byte
|
|
|
|
func main() {
|
|
fmt.Println("hello!")
|
|
|
|
// text, _ := io.ReadAll(os.Stdin)
|
|
|
|
var lis Entries
|
|
lis.Parse(string(todotxt))
|
|
|
|
type entry struct {
|
|
time time.Time
|
|
e Entry
|
|
}
|
|
|
|
// now := time.Date(time.Now().Year(), 1, 1, 0, 0, 0, 0, time.UTC)
|
|
pq := PriorityQueue(func(a, b *entry) bool {
|
|
return a.time.Before(b.time)
|
|
})
|
|
|
|
now := time.Now()
|
|
for e := range lis.Iter() {
|
|
for p := range e.Project(now, 365*24*time.Hour) {
|
|
pq.Insert(&entry{p, e})
|
|
}
|
|
}
|
|
var nlis []Entry
|
|
for !pq.IsEmpty() {
|
|
entry := pq.ExtractMin()
|
|
e, p := entry.e, entry.time
|
|
e.Title += p.Format(" rel:2006-01-02")
|
|
e.Attributes.Set("rel", p.Format("2006-01-02"))
|
|
nlis = append(nlis, e)
|
|
}
|
|
|
|
lis = NewEntries(nlis...)
|
|
|
|
fmt.Println(lis)
|
|
}
|