Documentation ¶
Index ¶
Constants ¶
const ( SQLDateTime = "2006-01-02 15:04:05" SQLDate = "2006-01-02" CST = "2006年01月02日 15:04:05 Z07" // China Standard Time )
Predefined time formats.
Variables ¶
var (
TZShanghai = time.FixedZone("UTC+8", 8*secondsOfHour)
)
Fixed time zones.
Functions ¶
Types ¶
type Date ¶
Date is used to save and output YYYY-MM-DD format date string.
func DateUTCFrom ¶ added in v0.9.1
func DateUTCNow ¶ added in v0.9.1
func DateUTCNow() Date
func (Date) MarshalJSON ¶
MarshalJSON converts a Time struct to ISO8601 string.
func (*Date) Scan ¶
Scan implements the Scanner interface. SQL NULL will be turned into time zero value.
func (*Date) UnmarshalJSON ¶
UnmarshalJSON converts ISO8601 data time into a Time struct. Empty string and null will be turned into time.Time zero value.
type Time ¶
Time is used to save and output ISO8601 date time with time zone set to UTC.
func TimeUTCFrom ¶ added in v0.9.1
func TimeUTCNow ¶ added in v0.9.1
func TimeUTCNow() Time
TimeUTCNow creates a Time instance with timezone set to UTC and truncated to second.
func (Time) MarshalJSON ¶
MarshalJSON converts a Time struct to ISO8601 string.
func (*Time) Scan ¶
Scan implements the Scanner interface. SQL NULL will be turned into time zero value.
func (Time) StringCN ¶
StringCN produces the string representation in Chinese format with locale set to Asia/Shanghai.
func (Time) StringEN ¶
StringEN produces the string representation in English with locale set to UTC.
func (*Time) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string in RFC 3339 format. Empty string and null will be turned into time.Time zero value.