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 Parse(layout, value string) (time.Time, error)
- 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
- type Constraints
- type DateTime
- type DefaultTime
- type DisplayTime
- type Duration
- type NanoTimeStamp
- func (ts NanoTimeStamp) Format(foramt string) string
- func (ts NanoTimeStamp) GormDataType() string
- func (t NanoTimeStamp) MarshalJSON() ([]byte, error)
- func (ts *NanoTimeStamp) Scan(value interface{}) (err error)
- func (t NanoTimeStamp) Time() time.Time
- func (t *NanoTimeStamp) UnmarshalJSON(data []byte) error
- func (ts NanoTimeStamp) Value() (driver.Value, error)
- type SecondTimeStamp
- func (ts SecondTimeStamp) Format(foramt string) string
- func (ts SecondTimeStamp) GormDataType() string
- func (t SecondTimeStamp) MarshalJSON() ([]byte, error)
- func (ts *SecondTimeStamp) Scan(value interface{}) (err error)
- func (t SecondTimeStamp) Time() time.Time
- func (t *SecondTimeStamp) UnmarshalJSON(data []byte) error
- func (ts SecondTimeStamp) Value() (driver.Value, error)
- 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]) UnmarshalBinary(data []byte) error
- func (dt *Time[T]) UnmarshalJSON(data []byte) error
- func (dt Time[T]) Value() (driver.Value, error)
- type Timestamp
- type Timestr
- type UnionTime
- type UnixMicroTime
- type UnixMilliTime
- type UnixNanoTime
- type UnixTime
Constants ¶
View Source
const ( SecondsOfDay = 24 * 60 * 60 SecondsOfMinute = 60 TimeDay = SecondsOfDay * time.Second )
View Source
const ( TimeFormat = "2006-01-02 15:04:05.999999" TimeFormatDisplay = "2006-01-02 15:04:05" TimeFormatPostgresDB = time.RFC3339 TimeFormatNoDate = "15:04:05" DayEndTime = "23:59:59" DayEndTimeWithSpace = " 23:59:59" DayBeginTime = "00:00:00" DayBeginTimeWithSpace = " 00:00:00" DateFormat = "2006-01-02" TimeFormatCompact = "20060102150405" TimeFormatRFC1 = "2006/01/02 - 15:04:05" )
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 StdDuration ¶
标准化TimeDuration
func SyncHwTime ¶
func SyncHwTime()
func TodayZeroTime ¶
Types ¶
type Constraints ¶ added in v1.6.15
type Constraints interface { DefaultTime | DateTime | UnixTime | UnixMilliTime | UnixNanoTime | DisplayTime }
type DefaultTime ¶ added in v1.6.15
type DefaultTime struct{}
type DisplayTime ¶ added in v1.6.15
type DisplayTime struct{}
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 NanoTimeStamp ¶ added in v1.6.15
type NanoTimeStamp int64
func (NanoTimeStamp) Format ¶ added in v1.6.15
func (ts NanoTimeStamp) Format(foramt string) string
func (NanoTimeStamp) GormDataType ¶ added in v1.6.15
func (ts NanoTimeStamp) GormDataType() string
GormDataType gorm common data type
func (NanoTimeStamp) MarshalJSON ¶ added in v1.6.15
func (t NanoTimeStamp) MarshalJSON() ([]byte, error)
func (*NanoTimeStamp) Scan ¶ added in v1.6.15
func (ts *NanoTimeStamp) Scan(value interface{}) (err error)
func (NanoTimeStamp) Time ¶ added in v1.6.15
func (t NanoTimeStamp) Time() time.Time
func (*NanoTimeStamp) UnmarshalJSON ¶ added in v1.6.15
func (t *NanoTimeStamp) UnmarshalJSON(data []byte) error
type SecondTimeStamp ¶ added in v1.6.15
type SecondTimeStamp int64
func (SecondTimeStamp) Format ¶ added in v1.6.15
func (ts SecondTimeStamp) Format(foramt string) string
func (SecondTimeStamp) GormDataType ¶ added in v1.6.15
func (ts SecondTimeStamp) GormDataType() string
GormDataType gorm common data type
func (SecondTimeStamp) MarshalJSON ¶ added in v1.6.15
func (t SecondTimeStamp) MarshalJSON() ([]byte, error)
func (*SecondTimeStamp) Scan ¶ added in v1.6.15
func (ts *SecondTimeStamp) Scan(value interface{}) (err error)
func (SecondTimeStamp) Time ¶ added in v1.6.15
func (t SecondTimeStamp) Time() time.Time
func (*SecondTimeStamp) UnmarshalJSON ¶ added in v1.6.15
func (t *SecondTimeStamp) UnmarshalJSON(data []byte) error
type Time ¶
TODO: 这是不优雅的实现
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 int64
毫秒
func NewTimeStamp ¶ added in v1.5.11
func (Timestamp) MarshalJSON ¶ added in v1.6.15
func (*Timestamp) UnmarshalJSON ¶ added in v1.6.15
type Timestr ¶ added in v1.6.15
type Timestr string
time.DateTime
func NewTimeStr ¶ added in v1.6.15
type UnionTime ¶
对应数据库datetime或timestamp,或date typ 0 序列化为 "2006-01-02 15:04:05",typ 1序列化为"2006-01-02",typ 2 序列化为秒时间戳, typ 3序列化为毫秒时间戳, typ 4 序列化为纳秒时间戳 序列化,反序列化前需设置typ
func ZeroUnionTime ¶
func (UnionTime) MarshalJSON ¶
func (*UnionTime) UnmarshalJSON ¶
type UnixMicroTime ¶ added in v1.6.15
type UnixMicroTime struct{}
type UnixMilliTime ¶ added in v1.6.15
type UnixMilliTime struct{}
type UnixNanoTime ¶
type UnixNanoTime struct{}
Click to show internal directories.
Click to hide internal directories.