xtime

package
v0.2.9 Latest Latest
Warning

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

Go to latest
Published: Feb 20, 2021 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

https://github.com/siddontang/go/tree/master/time2

Index

Constants

View Source
const (
	DateFormat         = "2006-01-02"
	UnixTimeUnitOffset = uint64(time.Millisecond / time.Nanosecond)
)

Variables

This section is empty.

Functions

func After

func After(d time.Duration) <-chan time.Time

After ...

func CurrentTimeMillis added in v0.2.5

func CurrentTimeMillis() uint64

Returns the current Unix timestamp in milliseconds.

func CurrentTimeMillsWithTicker added in v0.2.5

func CurrentTimeMillsWithTicker() uint64

func CurrentTimeNano added in v0.2.5

func CurrentTimeNano() uint64

Returns the current Unix timestamp in nanoseconds.

func Duration

func Duration(str string) time.Duration

Duration ... panic if parse duration failed

func Elapse

func Elapse(f func()) int64

Timing the cost of function call, unix nano was returned

func FormatDate added in v0.2.5

func FormatDate(tsMillis uint64) string

FormatDate formats Unix timestamp (ms) to date string

func FormatTimeMillis added in v0.2.5

func FormatTimeMillis(tsMillis uint64) string

FormatTimeMillis formats Unix timestamp (ms) to time string.

func GetTimestampInMilli

func GetTimestampInMilli() int64

GetTimestampInMilli ...

func IsLeapYear

func IsLeapYear(year int) bool

IsLeapYear ...

func NewRashTimer

func NewRashTimer(tick time.Duration) *rashTimer

NewRashTimer is the time for a jiffies

func Sleep

func Sleep(d time.Duration)

Sleep ...

func StartTimeTicker added in v0.2.5

func StartTimeTicker()

StartTimeTicker starts a background task that caches current timestamp per millisecond, which may provide better performance in high-concurrency scenarios.

func Tick

func Tick(d time.Duration) <-chan time.Time

Tick ...

Types

type Ticker

type Ticker struct {
	C <-chan time.Time
	// contains filtered or unexported fields
}

Ticker ...

func NewTicker

func NewTicker(d time.Duration) *Ticker

NewTicker ...

func TickFunc

func TickFunc(d time.Duration, f func()) *Ticker

TickFunc ...

func (*Ticker) Reset

func (t *Ticker) Reset(d time.Duration)

Reset ...

func (*Ticker) Stop

func (t *Ticker) Stop()

Stop ...

type Time

type Time struct {
	time.Time
}

Time time

func Now

func Now() *Time

Now returns current time

func Today

func Today() *Time

Today returns begin time of today

func Unix

func Unix(sec, nsec int64) *Time

Unix returns time converted from timestamp

func (*Time) BeginOfDay

func (t *Time) BeginOfDay() *Time

BeginOfDay returns zero point of time's day

func (*Time) BeginOfHour

func (t *Time) BeginOfHour() *Time

BeginOfHour returns zero point of time's day

func (*Time) BeginOfMinute

func (t *Time) BeginOfMinute() *Time

BeginOfMinute returns zero point of time's day

func (*Time) BeginOfMonth

func (t *Time) BeginOfMonth() *Time

BeginOfMonth begin of month

func (*Time) BeginOfWeek

func (t *Time) BeginOfWeek() *Time

BeginOfWeek the day of begin of week, NOTE: week begin from Sunday

func (*Time) BeginOfYear

func (t *Time) BeginOfYear() *Time

BeginOfYear BeginOfYear beginning of year

func (*Time) EndOfDay

func (t *Time) EndOfDay() *Time

EndOfDay returns last point of time's day

func (*Time) EndOfHour

func (t *Time) EndOfHour() *Time

EndOfHour returns last point of time's day

func (*Time) EndOfMinute

func (t *Time) EndOfMinute() *Time

EndOfMinute returns last point of time's day

func (*Time) EndOfMonth

func (t *Time) EndOfMonth() *Time

EndOfMonth end of month

func (*Time) EndOfWeek

func (t *Time) EndOfWeek() *Time

EndOfWeek end of week NOTE: week end with Saturday

func (*Time) EndOfYear

func (t *Time) EndOfYear() *Time

EndOfYear end of year

type TimeFormat added in v0.2.0

type TimeFormat string
var TS TimeFormat = "2006-01-02 15:04:05"

func (TimeFormat) Format added in v0.2.0

func (ts TimeFormat) Format(t time.Time) string

type Timer

type Timer struct {
	C <-chan time.Time
	// contains filtered or unexported fields
}

Timer ...

func AfterFunc

func AfterFunc(d time.Duration, f func()) *Timer

AfterFunc ...

func NewTimer

func NewTimer(d time.Duration) *Timer

NewTimer ...

func (*Timer) Reset

func (t *Timer) Reset(d time.Duration)

Reset ...

func (*Timer) Stop

func (t *Timer) Stop()

Stop ...

Jump to

Keyboard shortcuts

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