tsutil

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 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 Days added in v0.1.18

func Days(t time.Time) int

Days returns days since epoch to t.

func Millis

func Millis(t time.Time) int64

Millis returns milliseconds since epoch to t. Returns 0 if t.IsZero().

func NowMillis added in v0.1.20

func NowMillis() int64

NowMillis returns now in milliseconds since epoch.

func ParseMillis

func ParseMillis(i interface{}) time.Time

ParseMillis returns time.Time from milliseconds since epoch.

Types

type Clock

type Clock interface {
	// Now returns current clock time.
	Now() time.Time

	// NowMillis returns current time in milliseconds.
	NowMillis() int64

	// Add time to clock.
	Add(dt time.Duration)
}

Clock returns time.Time.

func NewClock

func NewClock() Clock

NewClock returns current clock time.

func NewTestClock added in v0.1.2

func NewTestClock() Clock

NewTestClock returns a test Clock starting at 1234567890000 millseconds since epoch. Each access to Now() increases time by 1 millisecond.

func NewTestClockAt added in v0.1.2

func NewTestClockAt(ts int64) Clock

NewTestClockAt creates a Clock starting at timestamp (millis).

Jump to

Keyboard shortcuts

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