data

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2024 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	NoTask     = errors.New("no task")
	NoTaskSucc = errors.New("no succeeding task")
	NoTaskPred = errors.New("no preceding task")
)
View Source
var Load = loadFunc
View Source
var Save = saveFunc

Functions

func MockLoadSave

func MockLoadSave(t *testing.T, dayList *DayList)

MockLoadSave is a function that mocks the behavior of the data.Load and data.Save functions by replacing them with custom implementations. The original functions are stored and can be restored later by calling the returned function.

The mocked data.Load function always returns the provided dayList and nil error. The mocked data.Save function always returns nil error.

Should not be called from production code!

Types

type Day

type Day struct {
	Date     time.Time
	Tasks    []*Task
	Finished time.Time
}

func NewDay

func NewDay(date time.Time) *Day

func (*Day) AddNewPause

func (d *Day) AddNewPause(s time.Time, txt string) error

func (*Day) AddNewTask

func (d *Day) AddNewTask(s time.Time, txt string, tgs []string) error

func (*Day) AddTask

func (d *Day) AddTask(task *Task)

func (*Day) End

func (d *Day) End() time.Time

func (*Day) Finish

func (d *Day) Finish(f time.Time) error

func (*Day) IsEmpty

func (d *Day) IsEmpty() bool

func (*Day) IsFinished

func (d *Day) IsFinished() bool

func (*Day) IsToday

func (d *Day) IsToday() bool

func (*Day) OvertimeDuration

func (d *Day) OvertimeDuration() (time.Duration, bool)

func (*Day) Pred

func (d *Day) Pred(task Task) (*Task, error)

func (*Day) RemoveTask

func (d *Day) RemoveTask(timeToDelete time.Time) bool

RemoveTask removes a task from the Day's list of tasks based on the specified time. It returns true if a task was found and removed, otherwise false.

func (*Day) Start

func (d *Day) Start() time.Time

func (*Day) Succ

func (d *Day) Succ(task Task) (*Task, error)

func (*Day) Tags

func (d *Day) Tags() []string

func (*Day) TaskDuration

func (d *Day) TaskDuration(task Task) time.Duration

func (*Day) TotalBreakDuration

func (d *Day) TotalBreakDuration() time.Duration

func (*Day) TotalDuration

func (d *Day) TotalDuration() time.Duration

func (*Day) TotalTagDuration

func (d *Day) TotalTagDuration(tag string) time.Duration

func (*Day) TotalWorkDuration

func (d *Day) TotalWorkDuration() time.Duration

func (*Day) Unfinished

func (d *Day) Unfinished()

type DayList

type DayList struct {
	Days []*Day
}

func (*DayList) Day

func (dl *DayList) Day(date time.Time) *Day

Day returns the Day struct for the specified date.

The returned struct is a copy of the day. Changes to this day won't be applied to the data model automatically.

func (*DayList) SanitizedDays

func (dl *DayList) SanitizedDays() []*Day

func (*DayList) Week

func (dl *DayList) Week(start time.Time) Week

type Task

type Task struct {
	Start   time.Time
	Text    string
	IsPause bool
	Tags    []string
}

func NewPause

func NewPause(s time.Time, tx string) *Task

func NewTask

func NewTask(s time.Time, tx string, tgs ...string) *Task

type Week

type Week struct {
	Days [7]Day
}

func (Week) TotalOvertimeDuration

func (w Week) TotalOvertimeDuration() (time.Duration, bool)

func (Week) TotalWorkDuration

func (w Week) TotalWorkDuration() time.Duration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL