โ– humdrum codex / ticktock v0.0.2
license AGPL-3.0
685 B raw
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
package store

import "time"

// Entry is one tock activity for a day.
type Entry struct {
	Key         string    // "YYYY-MM-DD-NN" โ€” tock's date-index
	Start       time.Time // wall clock
	End         time.Time // zero => running
	Project     string
	Description string
	Tags        []string
	Notes       string
	Duration    time.Duration
}

// Running reports whether the entry has no end time yet.
func (e Entry) Running() bool { return e.End.IsZero() }

// Store is the tock adapter. tock stays the source of truth.
type Store interface {
	Day(date string) ([]Entry, error)
	Add(e Entry) error
	Remove(key string) error
	SafeReplace(key string, updated, original Entry) error
}