tsutil

package
v0.1.3-0...-3c80581 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2020 License: MIT Imports: 2 Imported by: 0

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

func ConvertMillis(n int64) time.Time

ConvertMillis returns time.Time from milliseconds since epoch.

func Millis

func Millis(t time.Time) int64

Millis returns milliseconds since epoch from time.Time. Returns 0 if t.IsZero().

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

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

Clock returns time.Time.

func NewClock

func NewClock() Clock

NewClock returns current clock time.

func NewTestClock

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

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