Versions in this module Expand all Collapse all v0 v0.1.0 Jul 26, 2026 Changes in this version + var ErrAlreadyPaused = errors.New("sundial: timer already paused") + var ErrBadBudget = errors.New("sundial: Budget must not be negative") + var ErrBadLevels = errors.New("sundial: invalid levels") + var ErrBadSchedule = errors.New("sundial: invalid schedule") + var ErrBadSnapshot = errors.New("sundial: malformed snapshot") + var ErrBadWindow = errors.New("sundial: invalid window") + var ErrNotPaused = errors.New("sundial: timer not paused") + func Holidays(dates ...Date) map[Date]struct + func Weekdays(windows ...Window) [7][]Window + type Config struct + Budget time.Duration + Levels []Level + Schedule Schedule + type Date struct + Day int + Month time.Month + Year int + func On(year int, month time.Month, day int) Date + func (d *Date) UnmarshalJSON(b []byte) error + func (d Date) MarshalJSON() ([]byte, error) + func (d Date) String() string + type DayTime struct + Hour int + Min int + Sec int + func At(hour, minute, second int) DayTime + func (dt *DayTime) UnmarshalJSON(b []byte) error + func (dt DayTime) MarshalJSON() ([]byte, error) + func (dt DayTime) String() string + type Firing struct + At time.Time + Level Level + type Level struct + At time.Duration + Name string + type LevelFiring struct + At time.Time + Index int + type PauseSpan struct + End time.Time + Open bool + Start time.Time + type Schedule struct + Holidays map[Date]struct{} + Loc *time.Location + Week [7][]Window + func (s *Schedule) UnmarshalJSON(b []byte) error + func (s Schedule) Add(start time.Time, d time.Duration) time.Time + func (s Schedule) MarshalJSON() ([]byte, error) + func (s Schedule) Validate() error + func (s Schedule) Working(from, to time.Time) time.Duration + type Snapshot struct + Breached bool + BreachedAt time.Time + Clock time.Time + Fired []LevelFiring + Pauses []PauseSpan + Start time.Time + type Timer struct + func Restore(cfg Config, s Snapshot) (*Timer, error) + func Start(cfg Config, start time.Time) (*Timer, error) + func (t *Timer) Breached(now time.Time) bool + func (t *Timer) BreachedAt() (time.Time, bool) + func (t *Timer) DueAt() time.Time + func (t *Timer) Elapsed(now time.Time) time.Duration + func (t *Timer) Fired(now time.Time) []Firing + func (t *Timer) Pause(at time.Time) error + func (t *Timer) Paused() bool + func (t *Timer) Remaining(now time.Time) time.Duration + func (t *Timer) Resume(at time.Time) error + func (t *Timer) Snapshot() Snapshot + func (t *Timer) Start() time.Time + type Window struct + Close DayTime + Open DayTime