tsutil

package
v0.1.19 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 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 ConvertMillis added in v0.1.2

func ConvertMillis(n int64) time.Time

ConvertMillis returns time.Time from milliseconds since epoch.

func Days added in v0.1.18

func Days(t time.Time) int

Days returns milliseconds 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 MillisNow added in v0.1.18

func MillisNow() int64

MillisNow returns now in milliseconds since epoch.

func ParseMillis

func ParseMillis(s string) time.Time

ParseMillis returns time.Time from milliseconds since epoch as string.

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