atime

package
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrLayout = errors.New(`parse layout failed`)
)

Functions

func SetTimeZone added in v1.2.6

func SetTimeZone(zone string) error

SetTimeZone creates and returns a Time object with given timestamp Set time zone 设置时区

Types

type Times added in v1.2.6

type Times struct {
	Time time.Time
}

func New added in v1.2.6

func New(param ...interface{}) *Times

New 创建对象

func NewFromTimeStamp added in v1.2.6

func NewFromTimeStamp(timestamp int64) *Times

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 Now

func Now() *Times

Now Initialization time

func StrToTime added in v1.2.6

func StrToTime(str string) *Times

StrToTime String转Time

func WithDate

func WithDate(year, month, date, hour, minute, second int) *Times

WithDate ...

func WithTime

func WithTime(t time.Time) *Times

WithTime Include time

func (*Times) Add added in v1.2.7

func (t *Times) Add(d time.Duration) *Times

Add returns the time t+d.

func (*Times) AddDate added in v1.2.7

func (t *Times) AddDate(years int, months int, days int) *Times

AddDate adds year, month and day to the time.

func (*Times) After added in v1.2.7

func (t *Times) After(u *Times) bool

After reports whether the time instant t is after u.

func (*Times) Before added in v1.2.7

func (t *Times) Before(u *Times) bool

Before reports whether the time instant t is before u.

func (*Times) EndOfDay added in v1.2.6

func (t *Times) EndOfDay() *Times

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

func (t *Times) EndOfHalf() *Times

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

func (t *Times) EndOfHour() *Times

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

func (t *Times) EndOfMinute() *Times

EndOfMinute clones and returns a new time of which the seconds is set to 59.

func (*Times) EndOfMonth added in v1.2.6

func (t *Times) EndOfMonth() *Times

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

func (t *Times) EndOfQuarter() *Times

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

func (t *Times) EndOfWeek() *Times

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

func (t *Times) EndOfYear() *Times

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

func (t *Times) Equal(u *Times) bool

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) Format added in v1.2.6

func (t *Times) Format(layout string, chinese ...bool) string

Format ...

func (*Times) IsZero added in v1.2.7

func (t *Times) IsZero() bool

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

func (t *Times) MarshalJSON() ([]byte, error)

MarshalJSON implements the interface MarshalJSON for json.Marshal.

func (*Times) Microsecond added in v1.2.6

func (t *Times) Microsecond() int64

Microsecond 微妙

func (*Times) Millisecond added in v1.2.6

func (t *Times) Millisecond() int64

Millisecond 毫秒

func (*Times) Month added in v1.2.7

func (t *Times) Month() int

Month 返回 t 指定的年份中的月份。

func (*Times) Nanosecond added in v1.2.6

func (t *Times) Nanosecond() int64

Nanosecond 纳秒

func (*Times) Second added in v1.2.7

func (t *Times) Second() int

Second 指定的分钟内的第二个偏移量 在 [0, 59] 范围内。

func (*Times) StartOfDay added in v1.2.6

func (t *Times) StartOfDay() *Times

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

func (t *Times) StartOfHalf() *Times

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

func (t *Times) StartOfHour() *Times

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

func (t *Times) StartOfMinute() *Times

StartOfMinute clones and returns a new time of which the seconds is set to 0.

func (*Times) StartOfMonth added in v1.2.6

func (t *Times) StartOfMonth() *Times

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

func (t *Times) StartOfQuarter() *Times

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

func (t *Times) StartOfWeek() *Times

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

func (t *Times) StartOfYear() *Times

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) String added in v1.2.6

func (t *Times) String() string

String returns current time object as string.

func (*Times) Sub added in v1.2.7

func (t *Times) Sub(u *Times) time.Duration

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) Timestamp added in v1.2.6

func (t *Times) Timestamp() int64

Timestamp Get timestamp.时间转时间戳

func (*Times) Truncate added in v1.2.7

func (t *Times) Truncate(d time.Duration) *Times

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) UTC added in v1.2.7

func (t *Times) UTC() *Times

UTC 将当前时间转换为 UTC 时区。

func (*Times) UnmarshalJSON added in v1.2.6

func (t *Times) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the interface UnmarshalJSON for json.Unmarshal.

Jump to

Keyboard shortcuts

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