timei

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2024 License: MIT Imports: 10 Imported by: 2

Documentation

Index

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
)

Variables

View Source
var ZeroTime = time.Time{}

Functions

func Format

func Format(t time.Time) string

func GetTodayZeroTime

func GetTodayZeroTime() time.Time

GetTodayZeroTime 返回今天零点的time

func GetTomorrowYMD

func GetTomorrowYMD(sep string) string

GetTomorrowYMD 得到以sep为分隔符的年、月、日字符串(明天)

func GetYM

func GetYM(time time.Time, sep string) string

GetYM 得到以sep为分隔符的年、月字符串(今天所属于的月份)

func GetYMD

func GetYMD(time time.Time, sep string) string

GetTodayYMD 得到以sep为分隔符的年、月、日字符串(今天)

func GetYesterdayYMD

func GetYesterdayYMD(sep string) string

GetYesterdayYMD 得到以sep为分隔符的年、月、日字符串(昨天)

func GetYesterdayZeroTime

func GetYesterdayZeroTime() time.Time

GetYesterdayZeroTime 返回昨天零点的time

func Parse

func Parse(layout, value string) (time.Time, error)

func SetUnixSysTime

func SetUnixSysTime(t time.Time)

设置系统时间

func StdDuration added in v1.6.0

func StdDuration(td time.Duration, stdTd time.Duration) time.Duration

标准化TimeDuration

func StrToIntMonth

func StrToIntMonth(month string) int

StrToIntMonth 字符串月份转整数月份

func SyncHwTime

func SyncHwTime()

func TimeCost

func TimeCost(start time.Time)

func TodayZeroTime

func TodayZeroTime() time.Time

func WeiboParse

func WeiboParse(t string) time.Time

Types

type Date

type Date time.Time

func (Date) Format

func (date Date) Format(foramt string) string

func (*Date) GobDecode

func (date *Date) GobDecode(data []byte) error

func (Date) GobEncode

func (date Date) GobEncode() ([]byte, error)

func (*Date) GormDataType

func (date *Date) GormDataType() string

GormDataType gorm common data type

func (Date) MarshalBinary

func (date Date) MarshalBinary() ([]byte, error)

func (Date) MarshalJSON

func (date Date) MarshalJSON() ([]byte, error)

func (*Date) Scan

func (date *Date) Scan(value interface{}) (err error)

func (*Date) UnmarshalBinary

func (date *Date) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*Date) UnmarshalJSON

func (date *Date) UnmarshalJSON(data []byte) error

func (Date) Value

func (date Date) Value() (driver.Value, error)

type Duration

type Duration time.Duration

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

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 (d *Duration) UnmarshalText(text []byte) error

UnmarshalText unmarshal text to duration.

type Time

type Time time.Time

func (Time) Format

func (dt Time) Format(foramt string) string

func (*Time) GobDecode

func (dt *Time) GobDecode(data []byte) error

func (Time) GobEncode

func (dt Time) GobEncode() ([]byte, error)

func (*Time) GormDataType

func (dt *Time) GormDataType() string

GormDataType gorm common data type

func (Time) MarshalBinary

func (dt Time) MarshalBinary() ([]byte, error)

func (Time) MarshalJSON

func (dt Time) MarshalJSON() ([]byte, error)

func (*Time) Scan

func (dt *Time) Scan(value interface{}) (err error)

func (*Time) UnmarshalBinary

func (dt *Time) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*Time) UnmarshalJSON

func (dt *Time) UnmarshalJSON(data []byte) error

func (Time) Value

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

type TimeStamp

type TimeStamp int64

type UnionTime

type UnionTime struct {
	time.Time
	// contains filtered or unexported fields
}

对应数据库datetime或timestamp,或date jsonType 0 序列化为 "2006-01-02 15:04:05",jsonType 1序列化为"2006-01-02",jsonType 2 序列化为秒时间戳, jsonType 3序列化为毫秒时间戳 序列化,反序列化前需设置typ

func NewUnionTime

func NewUnionTime(t time.Time, typ uint8) UnionTime

func ZeroUnionTime

func ZeroUnionTime(typ uint8) UnionTime

func (UnionTime) Format

func (ut UnionTime) Format(foramt string) string

func (*UnionTime) GobDecode

func (ut *UnionTime) GobDecode(data []byte) error

func (UnionTime) GobEncode

func (ut UnionTime) GobEncode() ([]byte, error)

func (*UnionTime) GormDataType

func (ut *UnionTime) GormDataType() string

GormDataType gorm common data type

func (UnionTime) MarshalBinary

func (ut UnionTime) MarshalBinary() ([]byte, error)

func (UnionTime) MarshalJSON

func (ut UnionTime) MarshalJSON() ([]byte, error)

func (*UnionTime) Scan

func (ut *UnionTime) Scan(value interface{}) (err error)

func (*UnionTime) Type

func (ut *UnionTime) Type(typ uint8) UnionTime

func (*UnionTime) UnmarshalBinary

func (ut *UnionTime) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*UnionTime) UnmarshalJSON

func (ut *UnionTime) UnmarshalJSON(data []byte) error

func (UnionTime) Value

func (ut UnionTime) Value() (driver.Value, error)

type UnixNanoTime

type UnixNanoTime time.Time

func (UnixNanoTime) Format

func (unt UnixNanoTime) Format(foramt string) string

func (*UnixNanoTime) GobDecode

func (unt *UnixNanoTime) GobDecode(data []byte) error

func (UnixNanoTime) GobEncode

func (unt UnixNanoTime) GobEncode() ([]byte, error)

func (*UnixNanoTime) GormDataType

func (unt *UnixNanoTime) GormDataType() string

GormDataType gorm common data type

func (UnixNanoTime) MarshalBinary

func (unt UnixNanoTime) MarshalBinary() ([]byte, error)

func (UnixNanoTime) MarshalJSON

func (unt UnixNanoTime) MarshalJSON() ([]byte, error)

func (*UnixNanoTime) Scan

func (unt *UnixNanoTime) Scan(value interface{}) (err error)

func (*UnixNanoTime) UnmarshalBinary

func (unt *UnixNanoTime) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*UnixNanoTime) UnmarshalJSON

func (unt *UnixNanoTime) UnmarshalJSON(data []byte) error

func (UnixNanoTime) Value

func (unt UnixNanoTime) Value() (driver.Value, error)

type UnixNanoTimeStamp

type UnixNanoTimeStamp int64

func (UnixNanoTimeStamp) Format

func (ts UnixNanoTimeStamp) Format(foramt string) string

func (UnixNanoTimeStamp) GormDataType

func (ts UnixNanoTimeStamp) GormDataType() string

GormDataType gorm common data type

func (*UnixNanoTimeStamp) Scan

func (ts *UnixNanoTimeStamp) Scan(value interface{}) (err error)

func (UnixNanoTimeStamp) Value

func (ts UnixNanoTimeStamp) Value() (driver.Value, error)

type UnixTime

type UnixTime time.Time

func (UnixTime) Format

func (ut UnixTime) Format(foramt string) string

func (*UnixTime) GobDecode

func (ut *UnixTime) GobDecode(data []byte) error

func (UnixTime) GobEncode

func (ut UnixTime) GobEncode() ([]byte, error)

func (*UnixTime) GormDataType

func (ut *UnixTime) GormDataType() string

GormDataType gorm common data type

func (UnixTime) MarshalBinary

func (ut UnixTime) MarshalBinary() ([]byte, error)

func (UnixTime) MarshalJSON

func (ut UnixTime) MarshalJSON() ([]byte, error)

func (*UnixTime) Scan

func (ut *UnixTime) Scan(value interface{}) (err error)

func (*UnixTime) UnmarshalBinary

func (ut *UnixTime) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.

func (*UnixTime) UnmarshalJSON

func (ut *UnixTime) UnmarshalJSON(data []byte) error

func (UnixTime) Value

func (ut UnixTime) Value() (driver.Value, error)

type UnixTimeStamp

type UnixTimeStamp int64

func (UnixTimeStamp) Format

func (ts UnixTimeStamp) Format(foramt string) string

func (UnixTimeStamp) GormDataType

func (ts UnixTimeStamp) GormDataType() string

GormDataType gorm common data type

func (*UnixTimeStamp) Scan

func (ts *UnixTimeStamp) Scan(value interface{}) (err error)

func (UnixTimeStamp) Value

func (ts UnixTimeStamp) Value() (driver.Value, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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