model

package
v0.0.0-...-57d6a8b Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Event

type Event = sticky.Event[Model]

Event is the same as sticky.Event

func GetEvent

func GetEvent(eventType string) Event

GetEvent returns an empty event for a name.

type Maybe

type Maybe[T any] struct {
	// contains filtered or unexported fields
}

Maybe is the value or null.

The zero value is null.

func Just

func Just[T any](value T) Maybe[T]

Just creates a Maybe with a value.

func (Maybe[T]) MarshalJSON

func (m Maybe[T]) MarshalJSON() ([]byte, error)

MarshalJSON encodes the value from json.

func (*Maybe[T]) UnmarshalJSON

func (m *Maybe[T]) UnmarshalJSON(bs []byte) error

UnmarshalJSON decodes the value from json.

func (Maybe[T]) Value

func (m Maybe[T]) Value() (value T, exist bool)

type Model

type Model struct {
	// contains filtered or unexported fields
}

Model holds the data in memory.

func New

func New() Model

New returns an initialized Model.

func (*Model) Billed

func (m *Model) Billed(ids []int, billed bool) Event

Billed set the billed status of many periodes.

func (Model) Delete

func (m Model) Delete(id int) Event

Delete removes an existing periode.

func (*Model) Edit

func (m *Model) Edit(id int, start Maybe[sticky.JSONTime], duration Maybe[sticky.JSONDuration], comment Maybe[string], billed Maybe[bool]) Event

Edit changes an existing periode.

func (*Model) Insert

func (m *Model) Insert(start time.Time, duration time.Duration, comment Maybe[string]) (int, Event)

Insert creates a new periode.

func (*Model) List

func (m *Model) List() []Periode

List returns all periodes.

func (*Model) Running

func (m *Model) Running() (start time.Time, comment Maybe[string], ok bool)

Running tells if the timer is currently running.

If its running, it returns the start time and the comment.

func (Model) Start

func (m Model) Start(comment Maybe[string]) Event

Start starts the timer.

func (Model) Stop

func (m Model) Stop(comment Maybe[string]) (int, Event)

Stop stops the timer.

type Periode

type Periode struct {
	ID       int
	Start    time.Time
	Duration time.Duration
	Comment  Maybe[string]
	Billed   bool
}

Periode is a duration of time.

Jump to

Keyboard shortcuts

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