Documentation ¶
Index ¶
- Constants
- Variables
- 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 MarshalJSON(t time.Time) ([]byte, error)
- func MarshalText(t time.Time) ([]byte, error)
- func Parse(layout, value string) (time.Time, error)
- func SetJsonType(typ EncodeType)
- func SetLayout(l string)
- 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 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 StrTime
- 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 Timestamp
- type TimestampConstraints
- type UnionTime
- type UnixMicroTime
- type UnixMilliTime
- type UnixNanoTime
- type UnixSecondTime
Constants ¶
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 FormatRelativeTime ¶ added in v1.5.11
func GetYesterdayYMD ¶
GetYesterdayYMD 得到以sep为分隔符的年、月、日字符串(昨天)
func SetJsonType ¶ added in v1.7.2
func SetJsonType(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 DateStr ¶ added in v1.5.11
func NewDateStr ¶ added in v1.5.11
type DateTime ¶ added in v1.5.11
type DateTime int64
func (DateTime) GormDataType ¶ added in v1.5.11
func (DateTime) MarshalJSON ¶ added in v1.5.11
func (*DateTime) UnmarshalJSON ¶ added in v1.5.11
type DateTimeStr ¶ added in v1.5.11
time.DateTime
func NewDateTimeStr ¶ added in v1.5.11
func NewDateTimeStr(t time.Time) DateTimeStr
type Duration ¶
Duration be used toml unmarshal string time, like 1s, 500ms.
func (Duration) MarshalText ¶ added in v1.1.0
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 EncodeType ¶ added in v1.5.11
type EncodeType int8
const ( EncodeTypeLayout EncodeType = iota EncodeTypeUnixSeconds EncodeTypeUnixMilliseconds EncodeTypeUnixMicroseconds EncodeTypeUnixNanoseconds )
type Encoding ¶ added in v1.5.11
type Encoding struct { EncodeType Layout string }
func (*Encoding) SetJsonType ¶ added in v1.7.3
func (u *Encoding) SetJsonType(typ EncodeType)
type MicroTimestamp ¶ added in v1.5.11
type MicroTimestamp = timestamp[MicroTime]
type MilliTimestamp ¶ added in v1.5.11
type MilliTimestamp = timestamp[MilliTime]
type NanoTimestamp ¶ added in v1.5.11
type NanoTimestamp = timestamp[NanoTime]
type RandTicker ¶ added in v1.5.11
type RandTicker struct {
// contains filtered or unexported fields
}
func NewRandTicker ¶ added in v1.5.11
func NewRandTicker(minInterval, maxInterval time.Duration) *RandTicker
minInterval:最小等待时间 maxInterval:最大等待时间 maxInterval-minInterval: 等待范围
func (*RandTicker) Stop ¶ added in v1.5.11
func (t *RandTicker) Stop() bool
func (*RandTicker) Wait ¶ added in v1.5.11
func (t *RandTicker) Wait()
type SecondTime ¶ added in v1.5.11
type SecondTime struct{}
func (SecondTime) Encoding ¶ added in v1.7.3
func (SecondTime) Encoding() *Encoding
type SecondTimestamp ¶ added in v1.5.11
type SecondTimestamp = timestamp[SecondTime]
type StrTime ¶ added in v1.7.2
func (StrTime[T]) MarshalJSON ¶ added in v1.7.2
func (*StrTime[T]) UnmarshalJSON ¶ added in v1.7.2
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 ¶
type Timestamp ¶ added in v1.5.11
type Timestamp = timestamp[MilliTime]
毫秒
func NewTimeStamp ¶ added in v1.5.11
type TimestampConstraints ¶ added in v1.5.11
type UnixMicroTime ¶ added in v1.6.15
type UnixMilliTime ¶ added in v1.6.15
type UnixNanoTime ¶
type UnixSecondTime ¶ added in v1.6.17
type UnixSecondTime = Time[SecondTime]
Click to show internal directories.
Click to hide internal directories.