clock

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 13, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromUnixtimestamp

func FromUnixtimestamp(i int64) time.Time

func ParseRFC3339

func ParseRFC3339(ts string) (time.Time, error)

func RFC3339

func RFC3339(t time.Time) string

func Unixtimestamp

func Unixtimestamp(t time.Time) int64

func Y2KTime

func Y2KTime() time.Time

Types

type ConcreteTimeProvider

type ConcreteTimeProvider struct{}

func (ConcreteTimeProvider) Now

func (c ConcreteTimeProvider) Now() time.Time

type FrozenTimeProvider

type FrozenTimeProvider struct {
	Current time.Time
}

This time provider is useful for unit tests, where you can "freeze" time to have concrete values you can test in the database

func (FrozenTimeProvider) Now

func (p FrozenTimeProvider) Now() time.Time

type TimeMachine

type TimeMachine struct {
	Current time.Time
}

This time provider is useful if you need to hop through time in your tests; for example, to test cache expiration or such

func (*TimeMachine) Now

func (p *TimeMachine) Now() time.Time

func (*TimeMachine) Travel

func (p *TimeMachine) Travel(newTime time.Time)

type TimeProvider

type TimeProvider interface {
	Now() time.Time
}

type Y2K

type Y2K struct {
	TimeProvider
}

This time provider is useful to just conveniently freeze time at the turn of the millenium and you never need fine-grained control of time

func (Y2K) Now

func (p Y2K) Now() time.Time

Jump to

Keyboard shortcuts

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