Documentation ¶
Index ¶
- Constants
- Variables
- func Check(x TimeCheck) uint
- func CheckValid(x TimeCheck) error
- func Format(t time.Time) string
- func FormatRelativeTime(fromTime time.Time) string
- func GetTodayZeroTime() time.Time
- func GetTomorrowYMD(sep string) string
- func GetYM(time time.Time, sep string) string
- func GetYMD(time time.Time, sep string) string
- func GetYesterdayYMD(sep string) string
- func GetYesterdayZeroTime() time.Time
- func IsValid(x TimeCheck) bool
- func MarshalJSON(t time.Time) ([]byte, error)
- func MarshalText(t time.Time) ([]byte, error)
- func Parse(layout, value string) (time.Time, error)
- func SetEncodingLayout(l string)
- func SetEncodingType(typ EncodeType)
- func SetUnixSysTime(t time.Time)
- func StdDuration(td time.Duration, stdTd time.Duration) time.Duration
- func StrToIntMonth(month string) int
- func SyncHwTime()
- func TimeCost(start time.Time) time.Duration
- func TodayZeroTime() time.Time
- func UnixNano(nsec int64) time.Time
- func UnmarshalJSON(t *time.Time, data []byte) error
- func UnmarshalText(t *time.Time, data []byte) error
- type Date
- type DateStr
- type DateTime
- type DateTimeStr
- type Duration
- type Edate
- type EdateTime
- type Encode
- type EncodeTime
- type EncodeType
- type Encoding
- type Etime
- type FixTicker
- type Layout
- type MicroTime
- type MicroTimestamp
- type MilliTime
- type MilliTimestamp
- type NanoTime
- type NanoTimestamp
- type RandTicker
- type SecondTime
- type SecondTimestamp
- type Ticker
- type Time
- func (dt Time[T]) Format(format string) string
- func (dt *Time[T]) GobDecode(data []byte) error
- func (dt Time[T]) GobEncode() ([]byte, error)
- func (dt Time[T]) GormDataType() string
- func (dt Time[T]) MarshalBinary() ([]byte, error)
- func (dt Time[T]) MarshalJSON() ([]byte, error)
- func (dt *Time[T]) Scan(value interface{}) (err error)
- func (dt Time[T]) Time() time.Time
- func (dt *Time[T]) UnmarshalBinary(data []byte) error
- func (dt *Time[T]) UnmarshalJSON(data []byte) error
- func (dt Time[T]) Value() (driver.Value, error)
- type TimeCheck
- type TimeStr
- type Timestamp
- type TimestampConstraints
Constants ¶
View Source
const ( InvalidNil InvalidUnderflow InvalidOverflow InvalidNanos )
View Source
const ( SecondsOfDay = 24 * 60 * 60 SecondsOfMinute = 60 TimeDay = SecondsOfDay * time.Second )
View Source
const ( LayoutTimeMacro = "2006-01-02 15:04:05.999999" LayoutDateTime = "2006-01-02 15:04:05" LayoutRFC3339 = time.RFC3339 LayoutTime = "15:04:05" LayoutDate = "2006-01-02" LayoutCompactTime = "20060102150405" LayoutRFC1 = "2006/01/02 - 15:04:05" )
View Source
const ( DayEndTime = "23:59:59" DayEndTimeWithSpace = " 23:59:59" DayBeginTime = "00:00:00" DayBeginTimeWithSpace = " 00:00:00" )
View Source
const ( Day = time.Hour * 24 MonthDay30 = Day * 30 MonthDay31 = Day * 31 MonthDay28 = Day * 28 MonthDay29 = Day * 29 Month = MonthDay30 YearDay365 = Day * 365 YearDay366 = Day * 366 Year = YearDay365 )
View Source
const ( January = "January" February = "February" March = "March" April = "April" May = "May" June = "June" July = "July" August = "August" September = "September" October = "October" November = "November" December = "December" )
View Source
const ( Monday = "Monday" Tuesday = "Tuesday" Wednesday = "Wednesday" Thursday = "Thursday" Friday = "Friday" Saturday = "Saturday" Sunday = "Sunday" )
Variables ¶
View Source
var ZeroTime = time.Time{}
Functions ¶
func CheckValid ¶
func FormatRelativeTime ¶
func GetYesterdayYMD ¶
GetYesterdayYMD 得到以sep为分隔符的年、月、日字符串(昨天)
func SetEncodingLayout ¶
func SetEncodingLayout(l string)
func SetEncodingType ¶
func SetEncodingType(typ EncodeType)
func StdDuration ¶
标准化TimeDuration
func SyncHwTime ¶
func SyncHwTime()
func TodayZeroTime ¶
Types ¶
type Date ¶
type Date int64
func (Date) GormDataType ¶
func (Date) MarshalJSON ¶
func (*Date) UnmarshalJSON ¶
type DateTime ¶
type DateTime int64
func (DateTime) GormDataType ¶
func (DateTime) MarshalJSON ¶
func (*DateTime) UnmarshalJSON ¶
type Duration ¶
Duration be used toml unmarshal string time, like 1s, 500ms.
func (Duration) MarshalText ¶
func (Duration) Shrink ¶
Shrink will decrease the duration by comparing with context's timeout duration and return new timeout\context\CancelFunc.
func (*Duration) UnmarshalText ¶
UnmarshalText unmarshal text to duration.
type EncodeTime ¶ added in v0.1.1
func (EncodeTime) MarshalJSON ¶ added in v0.1.1
func (u EncodeTime) MarshalJSON() ([]byte, error)
func (*EncodeTime) UnmarshalJSON ¶ added in v0.1.1
func (u *EncodeTime) UnmarshalJSON(data []byte) error
type EncodeType ¶
type EncodeType int8
const ( EncodeTypeLayout EncodeType = iota EncodeTypeUnixSeconds EncodeTypeUnixMilliseconds EncodeTypeUnixMicroseconds EncodeTypeUnixNanoseconds )
type Encoding ¶
type Encoding struct { EncodeType Layout string }
func (*Encoding) SetType ¶
func (u *Encoding) SetType(typ EncodeType)
type MicroTimestamp ¶
type MicroTimestamp = timestamp[microTime]
type MilliTimestamp ¶
type MilliTimestamp = timestamp[milliTime]
type NanoTimestamp ¶
type NanoTimestamp = timestamp[nanoTime]
type RandTicker ¶
type RandTicker struct {
// contains filtered or unexported fields
}
func (*RandTicker) Channel ¶
func (t *RandTicker) Channel() <-chan time.Time
func (*RandTicker) Stop ¶
func (t *RandTicker) Stop() bool
func (*RandTicker) Wait ¶
func (t *RandTicker) Wait()
type SecondTime ¶
type SecondTime = Time[secondTime]
type SecondTimestamp ¶
type SecondTimestamp = timestamp[secondTime]
type Ticker ¶
func NewRandTicker ¶
minInterval:最小等待时间 maxInterval:最大等待时间 maxInterval-minInterval: 等待范围
type Time ¶
func (Time[T]) GormDataType ¶
func (Time[T]) MarshalBinary ¶
func (Time[T]) MarshalJSON ¶
func (*Time[T]) UnmarshalBinary ¶
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
func (*Time[T]) UnmarshalJSON ¶
Click to show internal directories.
Click to hide internal directories.