timex

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2022 License: MIT Imports: 1 Imported by: 0

README

timex

build-img pkg-img reportcard-img coverage-img version-img

Better time package for Go.

Rationale

TODO

Features

  • Simple.

See GUIDE.md for more details.

Install

Go version 1.17+

go get github.com/cristalhq/timex

Example

TODO

Documentation

See these docs.

License

MIT License.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FromUnix

func FromUnix(s int64) time.Time

FromUnix returns time from unix seconds.

func FromUnixMilli

func FromUnixMilli(ms int64) time.Time

FromUnixMilli returns time from unix milliseconds.

func FromUnixNano

func FromUnixNano(ns int64) time.Time

FromUnixNano returns time from unix nanoseconds.

func StopTimer

func StopTimer(t time.Timer)

StopTimer in a proper manner.

Types

type Clock

type Clock interface {
	Now() time.Time
}

Clock represents interface on time. Useful in tests.

func NewRealClock

func NewRealClock() Clock

NewRealClock returns real/system Clock.

type Duration

type Duration = time.Duration

Duration is an alias for time.Duration.

type ManualClock

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

ManualClock represents clock than can be controlled manually.

func NewManualClock

func NewManualClock(curr time.Time) *ManualClock

NewManualClock returns manual Clock with a given time.

func (*ManualClock) Add

func (c *ManualClock) Add(d time.Duration)

func (*ManualClock) Now

func (c *ManualClock) Now() time.Time

func (*ManualClock) Set

func (c *ManualClock) Set(t time.Time)

Jump to

Keyboard shortcuts

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