otime

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2021 License: MIT Imports: 3 Imported by: 0

Documentation

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 @Description: @param d @return <-chan

func CurrentTimeMillis

func CurrentTimeMillis() uint64

CurrentTimeMillis @Description: 当前时间的时间戳(毫秒) @return uint64

func CurrentTimeMillsWithTicker

func CurrentTimeMillsWithTicker() uint64

CurrentTimeMillsWithTicker @Description: 当前时间的定时器 @return uint64

func CurrentTimeNano

func CurrentTimeNano() uint64

CurrentTimeNano @Description: 当前时间的nanoseconds @return uint64

func Duration

func Duration(str string) time.Duration

func Elapse

func Elapse(f func()) int64

Elapse @Description:消费的时长 @param f @return int64

func FormatDate

func FormatDate(tsMillis uint64) string

FormatDate @Description: 格式化时间戳(毫秒)为字符串日期格式 @param tsMillis @return string

func FormatTimeMillis

func FormatTimeMillis(tsMillis uint64) string

FormatTimeMillis @Description: 格式化时间戳(毫秒)为字符串时间格式 @param tsMillis @return string

func GetTimestampInMilli

func GetTimestampInMilli() int64

GetTimestampInMilli @Description: @return int64

func IsLeapYear

func IsLeapYear(year int) bool

IsLeapYear @Description: 是否是闰年 @param year @return bool

func NewRashTimer

func NewRashTimer(tick time.Duration) *rashTimer

NewRashTimer is the time for a jiffies

func Sleep

func Sleep(d time.Duration)

Sleep @Description: @param d

func StartTimeTicker

func StartTimeTicker()

StartTimeTicker @Description: 开始时间定时器

func Tick

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

Tick @Description: 定时 @param d @return <-chan

Types

type Ticker

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

Ticker @Description: 定时器

func NewTicker

func NewTicker(d time.Duration) *Ticker

NewTicker @Description: 新建定时器 @param d @return *Ticker

func TickFunc

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

TickFunc @Description: 定时方法 @param d @param f @return *Ticker

func (*Ticker) Reset

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

Reset @Description: 重启 @receiver t @param d

func (*Ticker) Stop

func (t *Ticker) Stop()

Stop @Description: 停止 @receiver t

type Time

type Time struct {
	time.Time
}

Time @Description: 时间

func Now

func Now() *Time

Now @Description: 返回当前时间 @return *Time

func Today

func Today() *Time

Today @Description: 今天的开始时间 @return *Time

func Unix

func Unix(sec, nsec int64) *Time

Unix @Description: 返回由时间戳转换的时间 @param sec @param nsec @return *Time

func (*Time) BeginOfDay

func (t *Time) BeginOfDay() *Time

BeginOfDay @Description: 此时间天的开始时间 @receiver t @return *Time

func (*Time) BeginOfHour

func (t *Time) BeginOfHour() *Time

BeginOfHour @Description: 此时间小时的开始时间 @receiver t @return *Time

func (*Time) BeginOfMinute

func (t *Time) BeginOfMinute() *Time

BeginOfMinute @Description: 此时间分钟的开始时间 @receiver t @return *Time

func (*Time) BeginOfMonth

func (t *Time) BeginOfMonth() *Time

BeginOfMonth @Description: 此时间年的开始月份 @receiver t @return *Time

func (*Time) BeginOfWeek

func (t *Time) BeginOfWeek() *Time

BeginOfWeek @Description: 此时间周的开始时间,注意:一周的开始日期是星期日 @receiver t @return *Time

func (*Time) BeginOfYear

func (t *Time) BeginOfYear() *Time

BeginOfYear @Description: 此时间年的开始时间 @receiver t @return *Time

func (*Time) EndOfDay

func (t *Time) EndOfDay() *Time

EndOfDay @Description: 此时间天的结束时间 @receiver t @return *Time

func (*Time) EndOfHour

func (t *Time) EndOfHour() *Time

EndOfHour @Description: 此时间小时的结束时间 @receiver t @return *Time

func (*Time) EndOfMinute

func (t *Time) EndOfMinute() *Time

EndOfMinute @Description: 此时间分钟的结束时间 @receiver t @return *Time

func (*Time) EndOfMonth

func (t *Time) EndOfMonth() *Time

EndOfMonth @Description: 此时间年的结束月份 @receiver t @return *Time

func (*Time) EndOfWeek

func (t *Time) EndOfWeek() *Time

EndOfWeek @Description: 此时间周的结束时间,注意:一周的结束日期是星期六 @receiver t @return *Time

func (*Time) EndOfYear

func (t *Time) EndOfYear() *Time

EndOfYear @Description: 此时间年的结束时间 @receiver t @return *Time

type TimeFormat

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

func (TimeFormat) Format

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

type Timer

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

func AfterFunc

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

AfterFunc @Description: @param d @param f @return *Timer

func NewTimer

func NewTimer(d time.Duration) *Timer

NewTimer @Description: @param d @return *Timer

func (*Timer) Reset

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

Reset @Description: @receiver t @param d

func (*Timer) Stop

func (t *Timer) Stop()

Stop @Description: @receiver t

Jump to

Keyboard shortcuts

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