timex

package
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 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

CurrentMillis return unix mills timestamp for now

func DaysDuration added in v1.2.1

func DaysDuration(days int) time.Duration

HoursDuration create time.Duration from hours

func EpochMillsTime added in v1.2.1

func EpochMillsTime(millis int64) time.Time

EpochMillsTime convert unix epoch mills to time

func EpochTime added in v1.2.1

func EpochTime(secs int64) time.Time

EpochTime convert unix epoch seconds to time

func HoursDuration added in v1.2.1

func HoursDuration(hours int) time.Duration

HoursDuration create time.Duration from hours

func MicrosDuration added in v1.2.1

func MicrosDuration(micros int) time.Duration

MicrosDuration create time.Duration from micro seconds

func MillisDuration added in v1.2.1

func MillisDuration(millis int) time.Duration

MillisDuration create time.Duration from milli seconds

func MinutesDuration added in v1.2.1

func MinutesDuration(minutes int) time.Duration

MinutesDuration create time.Duration from minutes

func NanosDuration added in v1.2.1

func NanosDuration(nanos int) time.Duration

NanosDuration create time.Duration from nano seconds

func ParseLocal added in v1.2.0

func ParseLocal(layout string, value string) (time.Time, error)

ParseLocal parse time string with layout, in local Location

func SecondsDuration added in v1.2.1

func SecondsDuration(seconds int) time.Duration

SecondsDuration create time.Duration from seconds

func ToEpochMills

func ToEpochMills(t time.Time) int64

ToEpochMills convert 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

NewStopwatch create new Stopwatch, not started.

func NewStopwatchStarted added in v1.0.1

func NewStopwatchStarted() *Stopwatch

NewStopwatchStarted create new Stopwatch, then start it.

func (*Stopwatch) Elapsed added in v1.0.1

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

Elapsed 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.

Jump to

Keyboard shortcuts

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