Documentation ¶
Overview ¶
Package timer operates the Focus countdown timer and handles the recovery of interrupted timers
Index ¶
- func Delete(db store.DB) error
- func Recover(db store.DB, ctx *cli.Context) (*Timer, *Session, error)
- type Remainder
- type Session
- func (s *Session) ElapsedTimeInSeconds() float64
- func (s *Session) IsResuming() bool
- func (s *Session) Normalise(c context.Context)
- func (s *Session) RealElapsedTimeInSeconds() float64
- func (s *Session) Remaining() Remainder
- func (s *Session) SetEndTime()
- func (s *Session) ToDBModel() *models.Session
- func (s *Session) UpdateEndTime()
- type Settled
- type Status
- type Timeline
- type Timer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Session ¶ added in v1.4.0
type Session struct { StartTime time.Time `json:"start_time"` EndTime time.Time `json:"end_time"` Name config.SessType `json:"name"` Tags []string `json:"tags"` Timeline []Timeline `json:"timeline"` Duration time.Duration `json:"duration"` Completed bool `json:"completed"` }
Session represents an active work or break session.
func (*Session) ElapsedTimeInSeconds ¶ added in v1.4.0
ElapsedTimeInSeconds returns the time elapsed for the current session in seconds using monotonic timings.
func (*Session) IsResuming ¶ added in v1.4.0
IsResuming determines if a session is being resumed or not.
func (*Session) Normalise ¶ added in v1.4.0
Normalise ensures that the end time for the current session perfectly correlates with what is required to complete the session. It mostly helps with normalising the end time when the system is suspended with a session in progress, and resumed at a later time in the future that surpasses the normal end time.
func (*Session) RealElapsedTimeInSeconds ¶ added in v1.4.1
RealElapsedTimeInSeconds returns the time elapsed for the current session in seconds using real timings.
func (*Session) Remaining ¶ added in v1.4.0
Remaining calculates the time remaining for the session to end.
func (*Session) SetEndTime ¶ added in v1.4.0
func (s *Session) SetEndTime()
SetEndTime calculates the end time for the current session.
func (*Session) ToDBModel ¶ added in v1.4.0
ToDBModel converts an active session to a database model.
func (*Session) UpdateEndTime ¶ added in v1.4.0
func (s *Session) UpdateEndTime()
UpdateEndTime sets the session end time to the current time.
type Status ¶ added in v1.4.0
type Status struct { EndTime time.Time `json:"end_date"` Name config.SessType `json:"name"` Tags []string `json:"tags"` WorkCycle int `json:"work_cycle"` LongBreakInterval int `json:"long_break_interval"` }
Status represents the status of a running timer.
type Timer ¶ added in v1.4.0
type Timer struct { Opts *config.TimerConfig `json:"opts"` SoundStream beep.Streamer `json:"-"` PausedTime time.Time `json:"paused_time"` StartTime time.Time `json:"start_time"` SessionKey time.Time `json:"session_key"` WorkCycle int `json:"work_cycle"` // contains filtered or unexported fields }
Timer represents a running timer.
func (*Timer) NewSession ¶ added in v1.4.0
func (t *Timer) NewSession( c context.Context, name config.SessType, startTime time.Time, ) *Session
NewSession initialises a new session.
func (*Timer) Persist ¶ added in v1.4.0
Persist saves the current timer and session to the database.
func (*Timer) ReportStatus ¶ added in v1.4.0
ReportStatus reports the status of the currently running timer.