timeutil

package
v0.0.0-...-4be01c1 Latest Latest
Warning

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

Go to latest
Published: Mar 6, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidTime = errors.New(`Invalid time`)
View Source
var (
	ErrOutOfOrderTimeInterval = errors.New("Time Interval is Out of Order")
)

Functions

func Format

func Format(t time.Time, months []string) string

TODO: remove this function (see gitlab issue #259)

func MustParseTime

func MustParseTime(s string) time.Time

MustParseTime parses a time in the format `2006-01-02 15:04:05 -0700` and panics in case the parsing fails

func PrettyFormatTime

func PrettyFormatTime(time time.Time, language string) string

TODO: remove this function (see gitlab issue #259)

Types

type Clock

type Clock interface {
	Now() time.Time
	Sleep(time.Duration)
}

type FakeClock

type FakeClock struct {
	// Locking used just to prevent the race detector of triggering errors during tests
	sync.Mutex
	time.Time
}

func (*FakeClock) Now

func (t *FakeClock) Now() time.Time

func (*FakeClock) Sleep

func (t *FakeClock) Sleep(d time.Duration)

type RealClock

type RealClock struct{}

func (RealClock) Now

func (RealClock) Now() time.Time

func (RealClock) Sleep

func (RealClock) Sleep(d time.Duration)

type TimeInterval

type TimeInterval struct {
	From time.Time `json:"from"`
	To   time.Time `json:"to"`
}

func MustParseTimeInterval

func MustParseTimeInterval(from, to string) TimeInterval

func ParseTimeInterval

func ParseTimeInterval(fromStr string, toStr string, location *time.Location) (TimeInterval, error)

func (TimeInterval) IsZero

func (i TimeInterval) IsZero() bool

Jump to

Keyboard shortcuts

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