tsutil

package
v0.0.49 Latest Latest
Warning

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

Go to latest
Published: Jun 27, 2020 License: MIT Imports: 2 Imported by: 25

Documentation

Overview

Package tsutil provides timestamp and time utilities.

Index

Constants

View Source
const (
	// RFC3339Milli is RFC3339 with millisecond precision.
	RFC3339Milli = "2006-01-02T15:04:05.000Z07:00"
)

Variables

This section is empty.

Functions

func Millis

func Millis(t time.Time) int64

Millis returns milliseconds since epoch from time.Time. If t.IsZero() we return 0.

func ParseMillis

func ParseMillis(i interface{}) time.Time

ParseMillis returns time.Time from milliseconds since epoch.

Types

type Clock

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

Clock for time increments on each access. This is for testing.

func NewClock

func NewClock() *Clock

NewClock creates a Clock.

func NewClockAt

func NewClockAt(ts int64) *Clock

NewClockAt creates a Clock starting at timestamp (millis).

func (*Clock) Add

func (c *Clock) Add(dt time.Duration)

Add to clock.

func (*Clock) Now

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

Now returns current clock time.

func (*Clock) SetTick

func (c *Clock) SetTick(tick time.Duration)

SetTick sets tick increment for clock.

Jump to

Keyboard shortcuts

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