Documentation ¶
Index ¶
- Variables
- func SetTimeZone(zone string) error
- type Times
- func (t *Times) Add(d time.Duration) *Times
- func (t *Times) AddDate(years int, months int, days int) *Times
- func (t *Times) After(u *Times) bool
- func (t *Times) Before(u *Times) bool
- func (t *Times) EndOfDay() *Times
- func (t *Times) EndOfHalf() *Times
- func (t *Times) EndOfHour() *Times
- func (t *Times) EndOfMinute() *Times
- func (t *Times) EndOfMonth() *Times
- func (t *Times) EndOfQuarter() *Times
- func (t *Times) EndOfWeek() *Times
- func (t *Times) EndOfYear() *Times
- func (t *Times) Equal(u *Times) bool
- func (t *Times) Format(layout string, chinese ...bool) string
- func (t *Times) IsZero() bool
- func (t *Times) MarshalJSON() ([]byte, error)
- func (t *Times) Microsecond() int64
- func (t *Times) Millisecond() int64
- func (t *Times) Month() int
- func (t *Times) Nanosecond() int64
- func (t *Times) Second() int
- func (t *Times) StartOfDay() *Times
- func (t *Times) StartOfHalf() *Times
- func (t *Times) StartOfHour() *Times
- func (t *Times) StartOfMinute() *Times
- func (t *Times) StartOfMonth() *Times
- func (t *Times) StartOfQuarter() *Times
- func (t *Times) StartOfWeek() *Times
- func (t *Times) StartOfYear() *Times
- func (t *Times) String() string
- func (t *Times) Sub(u *Times) time.Duration
- func (t *Times) Timestamp() int64
- func (t *Times) Truncate(d time.Duration) *Times
- func (t *Times) UTC() *Times
- func (t *Times) UnmarshalJSON(b []byte) error
Constants ¶
This section is empty.
Variables ¶
var (
ErrLayout = errors.New(`parse layout failed`)
)
Functions ¶
func SetTimeZone ¶ added in v1.2.6
SetTimeZone creates and returns a Time object with given timestamp Set time zone 设置时区
Types ¶
type Times ¶ added in v1.2.6
func NewFromTimeStamp ¶ added in v1.2.6
NewFromTimeStamp creates and returns a Time object with given timestamp, which can be in seconds to nanoseconds. Eg: 1600443866 and 1600443866199266000 are both considered as valid timestamp number.
func (*Times) EndOfDay ¶ added in v1.2.6
EndOfDay clones and returns a new time which is the end of day the and its time is set to 23:59:59.
func (*Times) EndOfHalf ¶ added in v1.2.6
EndOfHalf clones and returns a new time which is the end of the half year and its time is set to 23:59:59.
func (*Times) EndOfHour ¶ added in v1.2.6
EndOfHour clones and returns a new time of which the minutes and seconds are both set to 59.
func (*Times) EndOfMinute ¶ added in v1.2.6
EndOfMinute clones and returns a new time of which the seconds is set to 59.
func (*Times) EndOfMonth ¶ added in v1.2.6
EndOfMonth clones and returns a new time which is the end of the month and its time is set to 23:59:59.
func (*Times) EndOfQuarter ¶ added in v1.2.6
EndOfQuarter clones and returns a new time which is end of the quarter and its time is set to 23:59:59.
func (*Times) EndOfWeek ¶ added in v1.2.6
EndOfWeek clones and returns a new time which is the end of week and its time is set to 23:59:59.
func (*Times) EndOfYear ¶ added in v1.2.6
EndOfYear clones and returns a new time which is the end of the year and its time is set to 23:59:59.
func (*Times) Equal ¶ added in v1.2.7
Equal reports whether t and u represent the same time instant. Two times can be equal even if they are in different locations. For example, 6:00 +0200 CEST and 4:00 UTC are Equal. See the documentation on the Time type for the pitfalls of using == with Time values; most code should use Equal instead.
func (*Times) IsZero ¶ added in v1.2.7
IsZero reports whether t represents the zero time instant, January 1, year 1, 00:00:00 UTC.
func (*Times) MarshalJSON ¶ added in v1.2.6
MarshalJSON implements the interface MarshalJSON for json.Marshal.
func (*Times) StartOfDay ¶ added in v1.2.6
StartOfDay clones and returns a new time which is the start of day, its time is set to 00:00:00.
func (*Times) StartOfHalf ¶ added in v1.2.6
StartOfHalf clones and returns a new time which is the first day of the half year and its time is set to 00:00:00.
func (*Times) StartOfHour ¶ added in v1.2.6
StartOfHour clones and returns a new time of which the hour, minutes and seconds are set to 0.
func (*Times) StartOfMinute ¶ added in v1.2.6
StartOfMinute clones and returns a new time of which the seconds is set to 0.
func (*Times) StartOfMonth ¶ added in v1.2.6
StartOfMonth clones and returns a new time which is the first day of the month and its is set to 00:00:00
func (*Times) StartOfQuarter ¶ added in v1.2.6
StartOfQuarter clones and returns a new time which is the first day of the quarter and its time is set to 00:00:00.
func (*Times) StartOfWeek ¶ added in v1.2.6
StartOfWeek clones and returns a new time which is the first day of week and its time is set to 00:00:00.
func (*Times) StartOfYear ¶ added in v1.2.6
StartOfYear clones and returns a new time which is the first day of the year and its time is set to 00:00:00.
func (*Times) Sub ¶ added in v1.2.7
Sub returns the duration t-u. If the result exceeds the maximum (or minimum) value that can be stored in a Duration, the maximum (or minimum) duration will be returned. To compute t-d for a duration d, use t.Add(-d).
func (*Times) Truncate ¶ added in v1.2.7
Truncate returns the result of rounding t down to a multiple of d (since the zero time). If d <= 0, Truncate returns t stripped of any monotonic clock reading but otherwise unchanged.
Truncate operates on the time as an absolute duration since the zero time; it does not operate on the presentation form of the time. Thus, Truncate(Hour) may return a time with a non-zero minute, depending on the time's Location.
func (*Times) UnmarshalJSON ¶ added in v1.2.6
UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.