timeconv

package
v2.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 3, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package timeconv provides time conversion capabilities to Trickster

Index

Constants

View Source
const (
	UnitMonth         = DurationUnit("mo")
	UnitMillisecond   = DurationUnit("ms")
	UnitMicrosecond   = DurationUnit("us")
	UnitMicrosecondB5 = DurationUnit("µs")
	UnitMicrosecondBC = DurationUnit("μs")
	UnitNanosecond    = DurationUnit("ns")
	UnitYear          = DurationUnit("y")
	UnitWeek          = DurationUnit("w")
	UnitDay           = DurationUnit("d")
	UnitHour          = DurationUnit("h")
	UnitMinute        = DurationUnit("m")
	UnitSecond        = DurationUnit("s")
	UnitMicro         = DurationUnit("u")
	UnitMicroB5       = DurationUnit("µ")
	UnitMicroBC       = DurationUnit("μ")
	UnitNil           = DurationUnit("nil")
)
View Source
const (
	Year        = Hour * 8760
	Month       = Hour * 730
	Week        = Day * 7
	Day         = Hour * 24
	Hour        = Minute * 60
	Minute      = Second * 60
	Second      = time.Second
	Millisecond = time.Millisecond
	Microsecond = time.Microsecond
	Nanosecond  = time.Nanosecond
)

Variables

Slice of units supported by the package. PLEASE NOTE that when parsing durations, these units will be checked in this order--for example, if minute "m" is before month "mo" or millisecond "ms", the parser will fail to recognize months and milliseconds in duration literals.

Functions

func ParseDuration

func ParseDuration(s string) (time.Duration, error)

ParseDuration returns a duration from a string. Slightly improved over the builtin, since it supports units larger than hour. Parse a literal duration. Durations are formatted as [signed int][unit]..., with each int-unit pair representing a number of those units of duration.

func SleepRandomMS

func SleepRandomMS(min, max int)

SleepRandomMS sleeps a random amount of MS between min and max (inclusive)

Types

type DurationUnit

type DurationUnit string

type InvalidDurationFormatError

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

func ErrInvalidDurationFormat

func ErrInvalidDurationFormat(pos int, expected string, in string) *InvalidDurationFormatError

func (*InvalidDurationFormatError) Error

func (err *InvalidDurationFormatError) Error() string

Jump to

Keyboard shortcuts

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