timelog

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: MIT Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const Version = "0.1.0"

Variables

This section is empty.

Functions

func CloneStrings

func CloneStrings(data []string) []string

CloneStrings duplicates []string in memory.

func FormatDate

func FormatDate(value time.Time) string

FormatDate formats date to string.

func FormatDateTime

func FormatDateTime(value time.Time) string

FormatDateTime formats datetime to string.

func FormatTime

func FormatTime(value time.Time) string

FormatTime formats time to string.

func HomeDir

func HomeDir() string

HomeDir returns user home dir path.

func ParseDateTime

func ParseDateTime(value string) (time.Time, error)

ParseDateTime parses time in app-default format.

func ReadTextFile

func ReadTextFile(file string) (string, error)

ReadTextFile reads text file from given.

func ToLocal

func ToLocal(t time.Time) time.Time

ToLocal converts time to local timezone.

func WriteTextFile

func WriteTextFile(dir string, file string, data string) error

WriteTextFile writes text file to given path ensuring folders exist.

Types

type AdjustEvent

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

AdjustEvent sent when adjusting minutes.

type AdjustPrinter

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

AdjustPrinter - stdout printer.

func (*AdjustPrinter) Print

func (p *AdjustPrinter) Print()

Print adjust lines for timelog to stdout.

func (AdjustPrinter) String

func (p AdjustPrinter) String() string

String returns text representation of timelog.

type AdjustService

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

AdjustService data.

func (*AdjustService) Run

func (p *AdjustService) Run(success func())

Run handles the service logic.

type Analytics

type Analytics struct {
	EntryNum int
	Duration
	LastDuration   Duration
	PrefixDuration map[string]Duration
	PrefixOrder    []string
}

Analytics for timelog.

type Archiver

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

Archiver

func (*Archiver) Archive

func (a *Archiver) Archive() (string, error)

Archive moves current data file to archive dir. archive dir is created if does not exist.

type ColoredDiffPrinter

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

ColoredDiffPrinter - timelogger diff printer with color.

func (*ColoredDiffPrinter) Print

func (p *ColoredDiffPrinter) Print()

Print outputs timelog diff to stdout.

func (*ColoredDiffPrinter) String

func (p *ColoredDiffPrinter) String() string

String returns colored diff representation of two timelogs.

type Config

type Config struct {
	Dir       string
	Quicklist []string
}

Config data.

func NewConfig

func NewConfig(dir string) *Config

NewConfig creates new config.

func Parse

func Parse(data []byte) (*Config, error)

Parse parses file data and returns Config.

func (*Config) ArchiveDir

func (c *Config) ArchiveDir() string

ArchivePath returns archive dir.

func (*Config) ConfigPath

func (c *Config) ConfigPath() string

ConfigPath returns configuration file path.

func (*Config) DataPath

func (c *Config) DataPath() string

DataPath returns data file path.

type DiffPrinter

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

DiffPrinter - timelogger diff printer.

func (*DiffPrinter) Print

func (p *DiffPrinter) Print()

Print outputs timelog diff to stdout.

func (*DiffPrinter) String

func (p *DiffPrinter) String() string

String returns diff representation of timelog.

type Duration

type Duration struct {
	Hours   int
	Minutes int
	Comment string
}

func (Duration) TotalString

func (d Duration) TotalString() string

type PolybarPrinter

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

PolybarPrinter - timelogger formatted for polybar output.

func (*PolybarPrinter) Print

func (p *PolybarPrinter) Print()

Print outputs timelog diff to stdout.

func (*PolybarPrinter) String

func (p *PolybarPrinter) String() string

String returns colored diff representation of two timelogs.

type Printer

type Printer interface {
	Print()
	String() string
}

Printer interface.

type Service

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

Service provides timeloggin functionallity and syncs data to files.

func NewService

func NewService(timelogger *TimeLogger) *Service

NewService creates timelog service.

func (*Service) Adjust

func (s *Service) Adjust(adjustments map[int]int) *TimeLogger

Adjust timelog.

func (*Service) Archiver

func (s *Service) Archiver() *Archiver

Archiver

func (*Service) Clear

func (s *Service) Clear()

Clear timelog and sync.

func (*Service) InstallAutocomplete

func (s *Service) InstallAutocomplete()

InstallAutocomplete saves sh files to config dir with autcomplete.

func (*Service) Load

func (s *Service) Load() (bool, error)

Load reads config and all time entries from files.

func (*Service) PolybarPrinter

func (s *Service) PolybarPrinter(format string) Printer

PolybarPrinter returns default stdout printer.

func (*Service) Quicklist

func (s *Service) Quicklist() []string

Quicklist returns qlist entries.

func (*Service) RunAdjustService

func (s *Service) RunAdjustService()

RunAdjustService runs adjust subservice.

func (*Service) Start

func (s *Service) Start(comment string)

Start timelog and sync.

func (*Service) Stop

func (s *Service) Stop()

Stop timelog and sync.

func (*Service) TextPrinter

func (s *Service) TextPrinter() Printer

TextPrinter returns default stdout printer.

type TextPrinter

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

TextPrinter - stdout printer.

func (*TextPrinter) Print

func (p *TextPrinter) Print()

Print outputs timelog to stdout.

func (*TextPrinter) String

func (p *TextPrinter) String() string

String returns text representation of timelog.

type TimeLogger

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

TimeLogger data.

func NewTimeLogger

func NewTimeLogger(c *Config) *TimeLogger

NewTimeLogger creates new time logger.

func (*TimeLogger) Adjust

func (t *TimeLogger) Adjust(adjustments map[int]int) *TimeLogger

Adjust takes adjustments map and applies time modifications based on provided values in minutes.

func (*TimeLogger) Clear

func (t *TimeLogger) Clear()

Clear clears all entries.

func (*TimeLogger) Start

func (t *TimeLogger) Start(comment string)

Start appends new time log entry closing last unclosed entry.

func (*TimeLogger) Stop

func (t *TimeLogger) Stop()

Stop closes existing unfinished entry.

func (*TimeLogger) Tokenize

func (t *TimeLogger) Tokenize(split bool) []Token

Tokenize generate list of tokens of how timelog output can be split.

type Token

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

Token represents timelog single part.

func (Token) Equals

func (t Token) Equals(other Token) bool

Equals checks if two tokens are identical.

Jump to

Keyboard shortcuts

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