Documentation
¶
Index ¶
- func FormatTime(tm time.Time, for_str string) string
- func GetDay0(timestamp int64) time.Time
- func GetDayStr(tm time.Time) string
- func GetHour(timestamp int64) int
- func GetHour0(timestamp int64) time.Time
- func GetLastDayCurrentTime(timestamp int64, offset int) time.Time
- func GetLocalTime(tm time.Time) time.Time
- func GetMonDay() int
- func GetMonth0(timestamp int64) time.Time
- func GetSeveralDaysAgo(day int) (start, end int)
- func GetSysTimeLayout() string
- func GetSystemCurDate() string
- func GetSystemCurTime() int
- func GetTimeStr(tm time.Time) string
- func GetTimeWeek(timestamp int64) int
- func GetToday() (start time.Time, end time.Time)
- func GetUtcDay0(now time.Time, timeZone *time.Location) int64
- func GetUtcTime(tm time.Time) int64
- func GetUtcWeek0(timestamp int64) int64
- func GetWeek0(timestamp int64) time.Time
- func GetYesterday() (start, end int)
- func StrToTime(tStr, format string, timeZone *time.Location) time.Time
- func StringTimetoUnix(timestr string) int64
- func TimerByHour(f func())
- func UnixToTime(timestamp int64) time.Time
- type Date
- func (d Date) AddDays(n int) Date
- func (d Date) Before(d2 Date) bool
- func (d Date) DaysSince(s Date) (days int)
- func (d Date) In(loc *time.Location) time.Time
- func (d Date) MarshalText() ([]byte, error)
- func (d *Date) Scan(value interface{}) error
- func (d Date) String() string
- func (d Date) ToTime() time.Time
- func (d *Date) UnmarshalText(data []byte) error
- func (d Date) Value() (driver.Value, error)
- type DateTime
- func (dt DateTime) Before(dt2 DateTime) bool
- func (dt DateTime) In(loc *time.Location) time.Time
- func (dt DateTime) MarshalText() ([]byte, error)
- func (dt *DateTime) Scan(value interface{}) error
- func (dt DateTime) String() string
- func (dt *DateTime) UnmarshalText(data []byte) error
- func (dt DateTime) Value() (driver.Value, error)
- type Time
- func (t Time) After(tm Time) bool
- func (t Time) MarshalJSON() ([]byte, error)
- func (t Time) MarshalText() ([]byte, error)
- func (t *Time) Scan(value interface{}) error
- func (t Time) String() string
- func (t Time) Subtract(t2 Time) int
- func (t Time) ToDate() time.Time
- func (t *Time) UnmarshalJSON(data []byte) (err error)
- func (t *Time) UnmarshalText(data []byte) error
- func (t Time) Value() (driver.Value, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetLastDayCurrentTime ¶ added in v0.2.19
获取offset天的现在时间:注意时区
func GetSeveralDaysAgo ¶
func GetSystemCurTime ¶
func GetSystemCurTime() int
GetSystemCurTime get system current time, nanoseconds value
func GetTimeStr ¶ added in v0.2.19
func GetUtcDay0 ¶ added in v0.2.19
获取offset 0点时间
func GetYesterday ¶
func GetYesterday() (start, end int)
func StringTimetoUnix ¶ added in v0.2.19
给定字符串时间转换成本地时间戳
Types ¶
type Date ¶
type Date struct {
Year int // Year (e.g., 2014).
Month time.Month // Month of the year (January = 1, ...).
Day int // Day of the month, starting at 1.
Valid bool
}
A Date represents a date (year, month, day).
This type does not include location information, and therefore does not describe a unique 24-hour timespan.
func ParseDate ¶
ParseDate parses a string in RFC3339 full-date format and returns the date value it represents.
func (Date) AddDays ¶
AddDays returns the date that is n days in the future. n can also be negative to go into the past.
func (Date) DaysSince ¶
DaysSince returns the signed number of days between the date and s, not including the end day. This is the inverse operation to AddDays.
func (Date) In ¶
In returns the time corresponding to time 00:00:00 of the date in the location.
In is always consistent with time.Date, even when time.Date returns a time on a different day. For example, if loc is America/Indiana/Vincennes, then both
time.Date(1955, time.May, 1, 0, 0, 0, 0, loc)
and
dt.Date{Year: 1955, Month: time.May, Day: 1}.In(loc)
return 23:00:00 on April 30, 1955.
In panics if loc is nil.
func (Date) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface. The output is the result of d.String().
func (*Date) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface. The date is expected to be a string in a format accepted by ParseDate.
type DateTime ¶
type DateTime struct {
Date Date
Time Time
}
A DateTime represents a date and time.
func DateTimeOf ¶
DateTimeOf returns the DateTime in which a time occurs in that time's location.
func ParseDateTime ¶
ParseDateTime parses a string and returns the DateTime it represents. ParseDateTime accepts a variant of the RFC3339 date-time format that omits the time offset but includes an optional fractional time, as described in ParseTime. Informally, the accepted format is
YYYY-MM-DDTHH:MM:SS[.FFFFFFFFF]
where the 'T' may be a lower-case 't'.
func (DateTime) In ¶
In returns the time corresponding to the DateTime in the given location.
If the time is missing or ambigous at the location, In returns the same result as time.Date. For example, if loc is America/Indiana/Vincennes, then both
time.Date(1955, time.May, 1, 0, 30, 0, 0, loc)
and
dt.DateTime{
dt.Date{Year: 1955, Month: time.May, Day: 1}},
dt.Time{Minute: 30}}.In(loc)
return 23:30:00 on April 30, 1955.
In panics if loc is nil.
func (DateTime) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface. The output is the result of dt.String().
func (*DateTime) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface. The datetime is expected to be a string in a format accepted by ParseDateTime
type Time ¶
json marsh 重写
func ParseTime ¶
ParseTime parses a string and returns the time value it represents. ParseTime accepts an extended form of the RFC3339 partial-time format. After the HH:MM:SS part of the string, an optional fractional part may appear, consisting of a decimal point followed by one to nine decimal digits. (RFC3339 admits only one digit after the decimal point).
func TimeOf ¶
TimeOf returns the Time representing the time of day in which a time occurs in that time's location. It ignores the date.
func (Time) MarshalJSON ¶ added in v0.2.19
func (Time) MarshalText ¶
MarshalText implements the encoding.TextMarshaler interface. The output is the result of d.String().
func (Time) String ¶
func (t Time) String() string
String returns the date in the format described in ParseTime. If Valid is not true, it will return empty string
func (Time) Subtract ¶
func (t Time) Subtract(t2 Time) int
Subtract returns difference between t and t2 in minutes
func (*Time) UnmarshalJSON ¶ added in v0.2.19
func (*Time) UnmarshalText ¶
UnmarshalText implements the encoding.TextUnmarshaler interface. The time is expected to be a string in a format accepted by ParseTime.