mstime

package
v0.12.13 Latest Latest
Warning

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

Go to latest
Published: Jul 6, 2023 License: ISC Imports: 2 Imported by: 13

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Since

func Since(t Time) time.Duration

Since returns the time elapsed since t. It is shorthand for Now().Sub(t).

Types

type Time

type Time struct {
	// contains filtered or unexported fields
}

Time is a wrapper for time.Time that guarantees all of its methods will return a millisecond precisioned times.

func Now

func Now() Time

Now returns the current local time, with precision of one millisecond.

func ToMSTime

func ToMSTime(t time.Time) Time

ToMSTime converts t to Time. See Time for details.

func UnixMilliseconds

func UnixMilliseconds(ms int64) Time

UnixMilliseconds returns the local Time corresponding to the given Unix time, ms milliseconds since January 1, 1970 UTC.

func (Time) Add

func (t Time) Add(d time.Duration) Time

Add returns the time t+d. It panics if d has a precision greater than one millisecond (the duration has a non zero microseconds part).

func (Time) After

func (t Time) After(u Time) bool

After reports whether the time instant t is after u.

func (Time) Before

func (t Time) Before(u Time) bool

Before reports whether the time instant t is before u.

func (Time) Clock

func (t Time) Clock() (hour, min, sec int)

Clock returns the hour, minute, and second within the day specified by t.

func (Time) Date

func (t Time) Date() (year int, month time.Month, day int)

Date returns the year, month, and day in which t occurs.

func (Time) IsZero

func (t Time) IsZero() bool

IsZero reports whether t represents the zero time instant, January 1, year 1, 00:00:00 UTC.

func (Time) Millisecond

func (t Time) Millisecond() int

Millisecond returns the millisecond offset within the second specified by t, in the range [0, 999].

func (Time) String

func (t Time) String() string

String returns the time formatted using the format string

"2006-01-02 15:04:05.999999999 -0700 MST"

func (Time) Sub

func (t Time) Sub(u Time) 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 (Time) ToNativeTime

func (t Time) ToNativeTime() time.Time

ToNativeTime converts t to time.Time

func (Time) UnixMilliseconds

func (t Time) UnixMilliseconds() int64

UnixMilliseconds returns t as a Unix time, the number of milliseconds elapsed since January 1, 1970 UTC.

func (Time) UnixSeconds

func (t Time) UnixSeconds() int64

UnixSeconds returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC.

Jump to

Keyboard shortcuts

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