time

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: BSD-2-Clause Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Date

func Date(t time.Time, location ...*time.Location) string

Date returns a date representation of the time value t.

func DateTime

func DateTime(t time.Time, location ...*time.Location) string

DateTime returns a datetime representation of the time value t.

func DoCycleTask

func DoCycleTask(ctx context.Context, f func(), d time.Duration)

DoCycleTask processing the cycle task with a period specified by the duration.

func Format

func Format(t time.Time, layout string, location ...*time.Location) string

Format returns a textual representation of the time value t formatted according to layout.

func HongKong

func HongKong() *time.Location

HongKong returns Hong Kong *time.Location.

func Local

func Local() *time.Location

Local returns Local *time.Location.

func Location

func Location(name string) *time.Location

Location returns *time.Location by location name.

func Now

func Now(location ...*time.Location) time.Time

Now returns now time.Time.

func NowAdd

func NowAdd(d time.Duration, location ...*time.Location) time.Time

NowAdd returns now added time.Time.

func NowAddDate

func NowAddDate(d time.Duration, location ...*time.Location) string

NowAddDate returns a date representation of now added time value.

func NowAddDateTime

func NowAddDateTime(d time.Duration, location ...*time.Location) string

NowAddDateTime returns a datetime representation of now added time value.

func NowAddFormat

func NowAddFormat(d time.Duration, layout string, location ...*time.Location) string

NowAddFormat returns a textual representation of now added time value formatted according to layout.

func NowAddUnixMicrosecond

func NowAddUnixMicrosecond(d time.Duration, location ...*time.Location) int64

NowAddUnixMicrosecond returns now added unix microsecond timestamp.

func NowAddUnixMillisecond

func NowAddUnixMillisecond(d time.Duration, location ...*time.Location) int64

NowAddUnixMillisecond returns now added unix millisecond timestamp.

func NowAddUnixNanosecond

func NowAddUnixNanosecond(d time.Duration, location ...*time.Location) int64

NowAddUnixNanosecond returns now added unix nanosecond timestamp.

func NowAddUnixSecond

func NowAddUnixSecond(d time.Duration, location ...*time.Location) int64

NowAddUnixSecond returns now added unix second timestamp.

func NowDate

func NowDate(location ...*time.Location) string

NowDate returns a date representation of now time value.

func NowDateTime

func NowDateTime(location ...*time.Location) string

NowDateTime returns a datetime representation of now time value.

func NowFormat

func NowFormat(layout string, location ...*time.Location) string

NowFormat returns a textual representation of now time value formatted according to layout.

func NowUnixMicrosecond

func NowUnixMicrosecond(location ...*time.Location) int64

NowUnixMicrosecond returns now unix microsecond timestamp.

func NowUnixMillisecond

func NowUnixMillisecond(location ...*time.Location) int64

NowUnixMillisecond returns now unix millisecond timestamp.

func NowUnixNanosecond

func NowUnixNanosecond(location ...*time.Location) int64

NowUnixNanosecond returns now unix nanosecond timestamp.

func NowUnixSecond

func NowUnixSecond(location ...*time.Location) int64

NowUnixSecond returns now unix second timestamp.

func Shanghai

func Shanghai() *time.Location

Shanghai returns Shanghai *time.Location.

func SleepMicrosecond

func SleepMicrosecond(n int64)

SleepMicrosecond pauses the current goroutine for at least n microsecond.

func SleepMillisecond

func SleepMillisecond(n int64)

SleepMillisecond pauses the current goroutine for at least n millisecond.

func SleepSecond

func SleepSecond(n int64)

SleepSecond pauses the current goroutine for at least n second.

func StringToTime

func StringToTime(str, layout string, location ...*time.Location) (time.Time, error)

StringToTime returns time.Time representation of str value parsed according to layout. layout example:

20060102150405
2006-01-02 15:04:05
2006/01/02 15/04/05

func StringToUnix

func StringToUnix(str, layout string, location ...*time.Location) int64

StringToUnix returns unix second timestamp representation of str value parsed according to layout. If str parsed err, it returns now unix second timestamp. layout example:

20060102150405
2006-01-02 15:04:05
2006/01/02 15/04/05

func UTC

func UTC() *time.Location

UTC returns UTC *time.Location.

func UnixAddDate

func UnixAddDate(timestamp int64, years, months, days int, location ...*time.Location) time.Time

UnixAddDate returns time.Time after unix timestamp has been added date.

func UnixAddDays

func UnixAddDays(timestamp int64, days int, location ...*time.Location) time.Time

UnixAddDays returns time.Time after unix timestamp has been added days.

func UnixAddMonths

func UnixAddMonths(timestamp int64, months int, location ...*time.Location) time.Time

UnixAddMonths returns time.Time after unix timestamp has been added months.

func UnixAddYears

func UnixAddYears(timestamp int64, years int, location ...*time.Location) time.Time

UnixAddYears returns time.Time after unix timestamp has been added years.

func UnixAfter

func UnixAfter(timestamp1, timestamp2 int64) bool

UnixAfter reports whether timestamp1 is after timestamp2.

func UnixBefore

func UnixBefore(timestamp1, timestamp2 int64) bool

UnixBefore reports whether timestamp1 is before timestamp2.

func UnixDifferDays

func UnixDifferDays(timestamp1, timestamp2 int64) int

UnixDifferDays returns the number of days between two timestamp.

func UnixDifferHours

func UnixDifferHours(timestamp1, timestamp2 int64) float64

UnixDifferHours returns the number of hours between two timestamp.

func UnixEqual

func UnixEqual(timestamp1, timestamp2 int64) bool

UnixEqual reports whether timestamp1 is equal timestamp2.

func UnixMicrosecond

func UnixMicrosecond(t time.Time, location ...*time.Location) int64

UnixMicrosecond returns t as unix microsecond timestamp.

func UnixMillisecond

func UnixMillisecond(t time.Time, location ...*time.Location) int64

UnixMillisecond returns t as unix millisecond timestamp.

func UnixNanosecond

func UnixNanosecond(t time.Time, location ...*time.Location) int64

UnixNanosecond returns t as unix nanosecond timestamp.

func UnixSecond

func UnixSecond(t time.Time, location ...*time.Location) int64

UnixSecond returns t as unix second timestamp.

func UnixToTime

func UnixToTime(timestamp int64, location ...*time.Location) time.Time

UnixToTime returns time.Time by unix timestamp.

func UnixTodayRange

func UnixTodayRange(location ...*time.Location) (int64, int64)

UnixTodayRange returns today start unix second timestamp and today end unix second timestamp.

Types

This section is empty.

Jump to

Keyboard shortcuts

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