Documentation
¶
Overview ¶
Package timer operates the Focus countdown timer and handles the recovery of interrupted timers
Index ¶
- Constants
- type Remainder
- type SessParams
- type Session
- func (s *Session) Adjust(since time.Time)
- func (s *Session) ElapsedTimeInSeconds() float64
- func (s *Session) IsResuming() bool
- func (s *Session) Normalise()
- func (s *Session) RealElapsedTimeInSeconds() float64
- func (s *Session) Remaining() Remainder
- func (s *Session) SetEndTime()
- func (s *Session) ToDBModel() *models.Session
- func (s *Session) UpdateEndTime(isCompleted bool)
- type Timeline
- type Timer
Constants ¶
const DefaultBufferSize = 10
DefaultBufferSize controls audio buffering.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type SessParams ¶
type SessParams map[config.SessionType]struct { Message string Duration time.Duration }
type Session ¶
type Session struct {
StartTime time.Time `json:"start_time"`
EndTime time.Time `json:"end_time"`
Name config.SessionType `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 ¶
ElapsedTimeInSeconds returns the time elapsed for the current session in seconds using monotonic timings.
func (*Session) IsResuming ¶
IsResuming determines if a session is being resumed or not.
func (*Session) Normalise ¶
func (s *Session) Normalise()
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 ¶
RealElapsedTimeInSeconds returns the time elapsed for the current session in seconds using real timings.
func (*Session) SetEndTime ¶
func (s *Session) SetEndTime()
SetEndTime calculates the end time for the current session.
func (*Session) UpdateEndTime ¶
UpdateEndTime sets the session end time to the current time.
type Timer ¶
type Timer struct {
SoundStream beep.Streamer `json:"-"`
Opts *config.Config `json:"opts"`
CurrentSess *Session
SessParams SessParams
WorkCycle int `json:"work_cycle"`
// contains filtered or unexported fields
}
Timer represents a running timer.
func (*Timer) Init ¶
Init initializes the timer for an interactive session, setting up the current session and its clock. It handles the special case where a completed session was added via --since reporting the successful addition and then exiting the application. Otherwise, for a new interactive session, it returns a command to initialize the timer's internal clock.
func (*Timer) ReportStatus ¶
ReportStatus reports the status of the currently running timer.