time

package
v0.0.0-...-89d9e6b Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2025 License: GPL-3.0, LGPL-3.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MiddleTimestamps

func MiddleTimestamps(earlier, later time.Time) time.Time

func NanotimeAsStringHex

func NanotimeAsStringHex(t time.Time) string

func TimeDeltaCorrectionFunc

func TimeDeltaCorrectionFunc(systemTime, currentTime *time.Time) func() time.Time

Types

type DateDuration

type DateDuration struct {
	Days   int
	Months int
	Years  int
}

FIXME provide convert to time.Duration type?

func ParseDateDuration

func ParseDateDuration(text string) (DateDuration, error)

ParseDateDuration is similar to ParseDuration but parses years, months, days. This is useful in `AddDate` function, that can processes larger durations.

Valid suffixes: y, year, years, m, month, months, w, week, weeks, d, day, days

An error is returned iff no valid duration could be parsed from the provided text.

Returns DateDuration, error

func ParseDateDurations

func ParseDateDurations(s string) (DateDuration, uint)

ParseDateDurations is similar to ParseDuration but parses years, months, days. This is useful in `AddDate` function, that can processes larger durations. ParseDateDurations splits input string in fields and parses each individual field. Fields that produce an error are skipped, incrementing the number of failures.

If failures == 0, all fields were properly parsed with no surprises, meaning that for each field a suitable suffix was recognized and a decimal value processed. For failures > 0, some --possibly all-- fields failed to process.

Valid suffixes: y, year, years, m, month, months, w, week, weeks, d, day, days Valid separators: any whitespace (see `unicode.IsSpace`), ',', ';'

Returns DateDuration, number of failures

func (*DateDuration) Add

func (d *DateDuration) Add(o *DateDuration)

func (*DateDuration) AddToTime

func (d *DateDuration) AddToTime(t *time.Time) time.Time

Jump to

Keyboard shortcuts

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