time

package module
v0.0.0-...-f56a457 Latest Latest
Warning

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

Go to latest
Published: Sep 27, 2022 License: MIT Imports: 5 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BeginOfMonthWithDayOffset

func BeginOfMonthWithDayOffset(monthOffset int, dayOffset int) time.Time

基于 <月初1号> 偏移 N 天(+, -)

func BeginningOfDayWithDayOffset

func BeginningOfDayWithDayOffset(offset int) time.Time

日初时刻: 当天+天偏移量(支持 +, - 偏移)

func BeginningOfMonthAgo

func BeginningOfMonthAgo() time.Time

月初时刻: 上个月

func BeginningOfMonthLater

func BeginningOfMonthLater() time.Time

月初时刻: 上个月

func BeginningOfMonthWithMonthOffset

func BeginningOfMonthWithMonthOffset(offset int) time.Time

月初时刻: 当前月+月偏移量(支持 +, - 偏移)

func Compare

func Compare(a time.Time, b time.Time) int32

func CurrentMonth

func CurrentMonth() string

本月:

func DayDurationWithDayOffset

func DayDurationWithDayOffset(offset int) (time.Time, time.Time)

日区间: 偏移量(支持 +, - 偏移)

func Duration10Bit

func Duration10Bit(hour int64, minute int64, second int64) float64

DurationWithSecond 别名

func Duration13Bit

func Duration13Bit(hour int64, minute int64, second int64) float64

DurationWithSecond 别名

func DurationWithMillisecond

func DurationWithMillisecond(hour int64, minute int64, second int64) float64

时间段: 单位 毫秒 (千分之一秒)

func DurationWithSecond

func DurationWithSecond(hour int64, minute int64, second int64) float64

////////////////////////////////////////////////////////////////// 时间段: 单位 秒(s)

func EndOfDayWithDayOffset

func EndOfDayWithDayOffset(offset int) time.Time

日末时刻: 当天+天偏移量(支持 +, - 偏移)

func EndOfMonthAgo

func EndOfMonthAgo() time.Time

月末时刻: 上个月

func EndOfMonthLater

func EndOfMonthLater() time.Time

月末时刻: 上个月

func EndOfMonthWithMonthOffset

func EndOfMonthWithMonthOffset(offset int) time.Time

月末时刻: 当前月+月偏移量(支持 +, - 偏移)

func Gen10BitTimestamp

func Gen10BitTimestamp() string

10bit:

func Gen10BitTs

func Gen10BitTs() int64

10bit: 单位: 秒 s

func Gen13BitTimestamp

func Gen13BitTimestamp() string

13bit: (19-6)

func Gen13BitTs

func Gen13BitTs() int64

13bit: (19-6) 单位: 毫秒

func Gen19BitTimestamp

func Gen19BitTimestamp() string

19bit:

func Gen19BitTs

func Gen19BitTs() int64

19bit: 单位: 纳秒(十亿分之一秒)

func Is13BitTimestampValid

func Is13BitTimestampValid(ts string, hour int64, minute int64, second int64) bool

时间戳是否过期:

func Is13BitTsValid

func Is13BitTsValid(ts int64, hour int64, minute int64, second int64) bool

时间戳是否过期:

func IsAfter

func IsAfter(a time.Time, b time.Time) bool

a>b

func IsBefore

func IsBefore(a time.Time, b time.Time) bool

a<b

func IsEqual

func IsEqual(a time.Time, b time.Time) bool

a=b:

func LastMonth

func LastMonth() string

上个月:

func MonthAgoDuration

func MonthAgoDuration() (time.Time, time.Time)

月份区间: 上个月

func MonthAgoDurationTs

func MonthAgoDurationTs() (int64, int64)

月份区间时间戳: 上个月

func MonthDurationWithMonthOffset

func MonthDurationWithMonthOffset(offset int) (time.Time, time.Time)

月份区间: 偏移量(支持 +, - 偏移)

func MonthLaterDuration

func MonthLaterDuration() (time.Time, time.Time)

月份区间: 下个月

func MonthWithOffset

func MonthWithOffset(offset int) string

月份+偏移量(支持 +, - 偏移): [格式: 2019-08]

func NextMonth

func NextMonth() string

下个月:

func Today

func Today() string

今日:

func TodayWithOffset

func TodayWithOffset(offset int) string

今天+偏移量(支持 +, - 偏移): [格式: 2019-08-23]

func Tomorrow

func Tomorrow() string

明日:

func Yesterday

func Yesterday() string

昨日:

Types

type Duration

type Duration stdTime.Duration

Duration be used toml unmarshal string time, like 1s, 500ms. extend for toml parse.

func (Duration) Shrink

Shrink will decrease the duration by comparing with context's timeout duration and return new timeout\context\CancelFunc.

func (*Duration) UnmarshalText

func (m *Duration) UnmarshalText(text []byte) error

UnmarshalText unmarshal text to duration.

type NowEx

type NowEx struct {
	*now.Now
}

扩展:

func New

func New(t time.Time) *NowEx

New initialize Now with time

func (*NowEx) BeginningOfDayWithDayOffset

func (now *NowEx) BeginningOfDayWithDayOffset(offset int) time.Time

日初时刻: 当天+偏移量(支持 +, - 偏移)

func (*NowEx) BeginningOfMonthAgo

func (now *NowEx) BeginningOfMonthAgo() time.Time

月初时刻: 上个月

func (*NowEx) BeginningOfMonthLater

func (now *NowEx) BeginningOfMonthLater() time.Time

月初时刻: 下个月

func (*NowEx) BeginningOfMonthWithMonthOffset

func (now *NowEx) BeginningOfMonthWithMonthOffset(offset int) time.Time

月初时刻: 当前月+偏移量(支持 +, - 偏移)

func (*NowEx) EndOfDayWithDayOffset

func (now *NowEx) EndOfDayWithDayOffset(offset int) time.Time

日末时刻: 当天+偏移量(支持 +, - 偏移)

func (*NowEx) EndOfMonthAgo

func (now *NowEx) EndOfMonthAgo() time.Time

月末时刻: 上个月

func (*NowEx) EndOfMonthLater

func (now *NowEx) EndOfMonthLater() time.Time

月末时刻: 下个月

func (*NowEx) EndOfMonthWithMonthOffset

func (now *NowEx) EndOfMonthWithMonthOffset(offset int) time.Time

月末时刻: 当前月+偏移量(支持 +, - 偏移)

type Time

type Time int64

Time be used to MySql timestamp converting.

func (*Time) Scan

func (m *Time) Scan(src interface{}) (err error)

Scan scan time.

func (Time) Time

func (m Time) Time() stdTime.Time

Time get time.

func (Time) Value

func (m Time) Value() (driver.Value, error)

Value get time value.

Jump to

Keyboard shortcuts

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