habits

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

func Load() (habitMap map[string]*Habit)

Load file if present, otherwise create and return empty map

func Save

func Save(habitMap map[string]*Habit)

Save persists the modified map to a file

Types

type Habit

type Habit struct {
	Name        string
	ShortName   string
	Tag         string
	Occurrences []time.Time
}

Habit is a represenation of a repeated task and its metadata Maintains a slice of timestamp occurrences

func New

func New(name, shortName, tag string) *Habit

New creates a new habit and return a pointer to it

func (*Habit) DaysSinceLastTick

func (h *Habit) DaysSinceLastTick() int

DaysSinceLastTick returns the integer number of days that have passed since the last occurrence

func (*Habit) Tick

func (h *Habit) Tick()

Tick indicates that an instance of the habit occurred by appending to `occurrences`

type HabitList

type HabitList []*Habit

HabitList is an array of Habit pointers

func (HabitList) Len

func (h HabitList) Len() int

func (HabitList) Less

func (h HabitList) Less(i, j int) bool

func (HabitList) Swap

func (h HabitList) Swap(i, j int)

type HabitMap

type HabitMap map[string]*Habit

HabitMap is a map of string to Habit pointers

Jump to

Keyboard shortcuts

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