timex

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Feb 29, 2020 License: BSD-2-Clause Imports: 1 Imported by: 0

Documentation

Index

Constants

View Source
const SimpleDate = "2006-01-02"
View Source
const SimpleTime = "2006-01-02 15:04:05"
View Source
const SimpleTimeMills = "2006-01-02 15:04:05.000"

Variables

This section is empty.

Functions

func CurrentMillis added in v1.0.1

func CurrentMillis() int64

Return unix mills timestamp for now

func Epoch

func Epoch(secs int64) time.Time

Epoch convert unix epoch seconds to time

func EpochMills

func EpochMills(millis int64) time.Time

EpochMills convert unix epoch mills to time

func ToEpochMills

func ToEpochMills(t time.Time) int64

time to unix epoch millis

Types

type Stopwatch added in v1.0.1

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

Stopwatch for measure elapsed time. This class is NOT thread-safe.

func NewStopwatch added in v1.0.1

func NewStopwatch() *Stopwatch

Create new Stopwatch, not started.

func NewStopwatchStarted added in v1.0.1

func NewStopwatchStarted() *Stopwatch

Create new Stopwatch, which is started.

func (*Stopwatch) Elapsed added in v1.0.1

func (w *Stopwatch) Elapsed() time.Duration

Return elapsed time. If not started, always return zero; If started and not stopped, return time interval from begin time to now; If stopped, return elapsed time duration from started time to stopped time.

func (*Stopwatch) Start added in v1.0.1

func (w *Stopwatch) Start() bool

Start the Stopwatch. If StopWatch is already started, return false. A stopped Stopwatch can start again.

func (*Stopwatch) Stop added in v1.0.1

func (w *Stopwatch) Stop() bool

Stop the Stopwatch. The elapsed time will not changed after stopped. Return true if stop succeed. If Stopwatch is not started, or already stopped, return false.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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