Documentation
¶
Index ¶
- Constants
- Variables
- func Check(x Time) uint
- func CheckValid(x Time) error
- func FormatRelativeTime(fromTime time.Time) string
- 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 IsValid(x Time) bool
- func MarshalJSON(t time.Time) ([]byte, error)
- func MarshalText(t time.Time) ([]byte, error)
- func NormalizeDuration(td time.Duration, stdTd time.Duration) time.Duration
- func ParseDate(t string) (time.Time, error)
- func ParseDateTime(t string) (time.Time, error)
- func ParseTime(t string) (time.Time, error)
- func SetSysTime(t time.Time)
- func StrToIntMonth(month string) int
- func SyncHwTime()
- 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
- func YesterdayZeroTime() time.Time
- type Date
- func (d *Date) GobDecode(data []byte) error
- func (d Date) GobEncode() ([]byte, error)
- func (d Date) GormDataType() string
- func (d Date) MarshalBinary() ([]byte, error)
- func (d Date) MarshalGQL(w io.Writer)
- func (d Date) MarshalJSON() ([]byte, error)
- func (d Date) MarshalText() ([]byte, error)
- func (d *Date) Scan(value interface{}) (err error)
- func (d Date) String() string
- func (d Date) Time() time.Time
- func (d *Date) UnmarshalBinary(data []byte) error
- func (d *Date) UnmarshalGQL(v interface{}) error
- func (d *Date) UnmarshalJSON(data []byte) error
- func (d *Date) UnmarshalText(data []byte) error
- func (d Date) Value() (driver.Value, error)
- type DateTime
- func (ts DateTime) Date() Date
- func (ts DateTime) GormDataType() string
- func (d DateTime) MarshalJSON() ([]byte, error)
- func (d DateTime) MarshalText() ([]byte, error)
- func (d *DateTime) Scan(value interface{}) (err error)
- func (d DateTime) Time() time.Time
- func (d *DateTime) UnmarshalJSON(data []byte) error
- func (d *DateTime) UnmarshalText(data []byte) error
- func (d DateTime) Value() (driver.Value, error)
- type Duration
- type Encoding
- type EncodingTime
- type FixedTicker
- type GlobEncodingTime
- type RandTicker
- type Ticker
- type Time
Constants ¶
View Source
const ( InvalidNil InvalidUnderflow InvalidOverflow InvalidNanos )
View Source
const ( LayoutTimeMacro = "2006-01-02 15:04:05.999999" LayoutCompactDate = "20060102" 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 SecondsOfDay = HoursOfDay * SecondsOfHour SecondsOfMinute = 60 SecondsOfHour = MinutesOfHour * SecondsOfMinute MinutesOfHour = 60 MinutesOfDay = MinutesOfHour * HoursOfDay HoursOfDay = 24 )
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 ( DefaultEncoding = &Encoding{ Layout: time.RFC3339Nano, } EncodingUnixSeconds = &Encoding{ encodeType: encodeTypeUnixSeconds, } EncodingUnixMilliseconds = &Encoding{ encodeType: encodeTypeUnixMilliseconds, } EncodingUnixMicroseconds = &Encoding{ encodeType: encodeTypeUnixMicroseconds, } EncodingUnixNanoseconds = &Encoding{ encodeType: encodeTypeUnixNanoseconds, } )
View Source
var ZeroTime = time.Time{}
Functions ¶
func CheckValid ¶
func FormatRelativeTime ¶
func GetYesterdayYMD ¶
GetYesterdayYMD 得到以sep为分隔符的年、月、日字符串(昨天)
func NormalizeDuration ¶ added in v1.3.20
标准化Duration
func SyncHwTime ¶
func SyncHwTime()
func YesterdayZeroTime ¶ added in v1.6.3
YesterdayZeroTime 返回昨天零点的time
Types ¶
type Date ¶
type Date int32
1-01-01~9999-12-31
func DateFromTime ¶
func DateTimeFromTime ¶
func (Date) GormDataType ¶
func (Date) MarshalBinary ¶
func (Date) MarshalGQL ¶
func (Date) MarshalJSON ¶
func (Date) MarshalText ¶
func (*Date) UnmarshalBinary ¶
UnmarshalBinary implements the DefaultEncoding.BinaryUnmarshaler interface.
func (*Date) UnmarshalGQL ¶
func (*Date) UnmarshalJSON ¶
func (*Date) UnmarshalText ¶
type DateTime ¶
type DateTime int64
01-01-01 00:00:00~9999-12-31 23:59:59
func (DateTime) GormDataType ¶
func (DateTime) MarshalJSON ¶
func (DateTime) MarshalText ¶
func (*DateTime) UnmarshalJSON ¶
func (*DateTime) UnmarshalText ¶
type Duration ¶
type Duration int64
Duration be used toml unmarshal string time, like 1s, 500ms.
func (Duration) MarshalJSON ¶ added in v1.6.7
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) UnmarshalJSON ¶ added in v1.6.7
UnmarshalJSON implements the encoding/json.Unmarshaler interface. The time must be a quoted string in the RFC 3339 format.
func (*Duration) UnmarshalText ¶
UnmarshalText unmarshal text to duration.
type Encoding ¶
type Encoding struct {
Layout string
// contains filtered or unexported fields
}
func NewLayOutEncoding ¶ added in v1.7.18
type EncodingTime ¶
func (EncodingTime) MarshalJSON ¶
func (u EncodingTime) MarshalJSON() ([]byte, error)
func (*EncodingTime) UnmarshalJSON ¶
func (u *EncodingTime) UnmarshalJSON(data []byte) error
type FixedTicker ¶ added in v1.7.18
func (*FixedTicker) Channel ¶ added in v1.7.18
func (t *FixedTicker) Channel() <-chan time.Time
func (*FixedTicker) Stop ¶ added in v1.7.18
func (t *FixedTicker) Stop() bool
func (*FixedTicker) Wait ¶ added in v1.7.18
func (t *FixedTicker) Wait()
type GlobEncodingTime ¶ added in v1.3.20
func (GlobEncodingTime) MarshalJSON ¶ added in v1.3.20
func (u GlobEncodingTime) MarshalJSON() ([]byte, error)
func (*GlobEncodingTime) UnmarshalJSON ¶ added in v1.3.20
func (u *GlobEncodingTime) UnmarshalJSON(data []byte) error
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 Ticker ¶
func NewRandTicker ¶
minInterval:最小等待时间 maxInterval:最大等待时间 maxInterval-minInterval: 等待范围
Click to show internal directories.
Click to hide internal directories.