All packages

    time

    import "time"

    Package time provides functionality for measuring and displaying time. The calendrical calculations always assume a Gregorian calendar, with no leap seconds. # Monotonic Clocks Operating systems provide both a “wall clock,” which is subject to changes for clock synchronization, and a “monotonic clock,” which is not. The general rule is that the wall clock is for telling time and the monotonic clock is for measuring time. Rather than split the API, in this package the Time returned ...

    Go 1.26.1

    Constants

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:111

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:128

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:127

    const (
    	Nanosecond  Duration = 1
    	Microsecond          = 1000 * Nanosecond
    	Millisecond          = 1000 * Microsecond
    	Second               = 1000 * Millisecond
    	Minute               = 60 * Second...

    Common durations. There is no definition for units of Day or larger to avoid confusion across daylight savings time zone transitions. To count the number of units in a [Duration], divide: second := time.Second fmt.Print(int64(second/time.Millisecond)) // prints 1000 To convert an integer number of units to a Duration, multiply: seconds := 10 fmt.Print(time.Duration(seconds)*time.Second) // prints 10s

    time/time.go:940

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:121

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:110

    const (
    	Nanosecond  Duration = 1
    	Microsecond          = 1000 * Nanosecond
    	Millisecond          = 1000 * Microsecond
    	Second               = 1000 * Millisecond
    	Minute               = 60 * Second...

    Common durations. There is no definition for units of Day or larger to avoid confusion across daylight savings time zone transitions. To count the number of units in a [Duration], divide: second := time.Second fmt.Print(int64(second/time.Millisecond)) // prints 1000 To convert an integer number of units to a Duration, multiply: seconds := 10 fmt.Print(time.Duration(seconds)*time.Second) // prints 10s

    time/time.go:936

    const (
    	Nanosecond  Duration = 1
    	Microsecond          = 1000 * Nanosecond
    	Millisecond          = 1000 * Microsecond
    	Second               = 1000 * Millisecond
    	Minute               = 60 * Second...

    Common durations. There is no definition for units of Day or larger to avoid confusion across daylight savings time zone transitions. To count the number of units in a [Duration], divide: second := time.Second fmt.Print(int64(second/time.Millisecond)) // prints 1000 To convert an integer number of units to a Duration, multiply: seconds := 10 fmt.Print(time.Duration(seconds)*time.Second) // prints 10s

    time/time.go:937

    const (
    	Nanosecond  Duration = 1
    	Microsecond          = 1000 * Nanosecond
    	Millisecond          = 1000 * Microsecond
    	Second               = 1000 * Millisecond
    	Minute               = 60 * Second...

    Common durations. There is no definition for units of Day or larger to avoid confusion across daylight savings time zone transitions. To count the number of units in a [Duration], divide: second := time.Second fmt.Print(int64(second/time.Millisecond)) // prints 1000 To convert an integer number of units to a Duration, multiply: seconds := 10 fmt.Print(time.Duration(seconds)*time.Second) // prints 10s

    time/time.go:939

    const (
    	Nanosecond  Duration = 1
    	Microsecond          = 1000 * Nanosecond
    	Millisecond          = 1000 * Microsecond
    	Second               = 1000 * Millisecond
    	Minute               = 60 * Second...

    Common durations. There is no definition for units of Day or larger to avoid confusion across daylight savings time zone transitions. To count the number of units in a [Duration], divide: second := time.Second fmt.Print(int64(second/time.Millisecond)) // prints 1000 To convert an integer number of units to a Duration, multiply: seconds := 10 fmt.Print(time.Duration(seconds)*time.Second) // prints 10s

    time/time.go:935

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:117

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:118

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:119

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:120

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:114

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:115

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:116

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:113

    const (
    	Nanosecond  Duration = 1
    	Microsecond          = 1000 * Nanosecond
    	Millisecond          = 1000 * Microsecond
    	Second               = 1000 * Millisecond
    	Minute               = 60 * Second...

    Common durations. There is no definition for units of Day or larger to avoid confusion across daylight savings time zone transitions. To count the number of units in a [Duration], divide: second := time.Second fmt.Print(int64(second/time.Millisecond)) // prints 1000 To convert an integer number of units to a Duration, multiply: seconds := 10 fmt.Print(time.Duration(seconds)*time.Second) // prints 10s

    time/time.go:938

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:123

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:125

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:124

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:126

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:129

    const (
    	Layout      = "01/02 03:04:05PM '06 -0700" // The reference time, in numerical order.
    	ANSIC       = "Mon Jan _2 15:04:05 2006"
    	UnixDate    = "Mon Jan _2 15:04:05 MST 2006"
    	RubyDate    =...

    These are predefined layouts for use in [Time.Format] and [time.Parse]. The reference time used in these layouts is the specific time stamp: 01/02 03:04:05PM '06 -0700 (January 2, 15:04:05, 2006, in time zone seven hours west of GMT). That value is recorded as the constant named [Layout], listed below. As a Unix time, this is 1136239445. Since MST is GMT-0700, the reference would be printed by the Unix date command as: Mon Jan 2 15:04:05 MST 2006 It is a regrettable historic error that ...

    time/format.go:112

    Functions

    func After(d Duration) <-chan Time

    After waits for the duration to elapse and then sends the current time on the returned channel. It is equivalent to [NewTimer](d).C. Before Go 1.23, this documentation warned that the underlying [Timer] would not be recovered by the garbage collector until the timer fired, and that if efficiency was a concern, code should use NewTimer instead and call [Timer.Stop] if the timer is no longer needed. As of Go 1.23, the garbage collector can recover unreferenced, unstopped timers. There is no re...

    time/sleep.go:202

    func AfterFunc(d Duration, f func(...)) *Timer

    AfterFunc waits for the duration to elapse and then calls f in its own goroutine. It returns a [Timer] that can be used to cancel the call using its Stop method. The returned Timer's C field is not used and will be nil.

    time/sleep.go:210

    func Date(year int, month Month, day int, hour int, min int, sec int, nsec int, loc *Location) Time

    Date returns the Time corresponding to yyyy-mm-dd hh:mm:ss + nsec nanoseconds in the appropriate zone for that time in the given location. The month, day, hour, min, sec, and nsec values may be outside their usual ranges and will be normalized during the conversion. For example, October 32 converts to November 1. A daylight savings time transition skips or repeats times. For example, in the United States, March 13, 2011 2:15am never occurred, while November 6, 2011 1:15am occurred twice....

    time/time.go:1734

    func FixedZone(name string, offset int) *Location

    FixedZone returns a [Location] that always uses the given zone name and offset (seconds east of UTC).

    time/zoneinfo.go:112

    func LoadLocation(name string) (*Location, error)

    LoadLocation returns the Location with the given name. If the name is "" or "UTC", LoadLocation returns UTC. If the name is "Local", LoadLocation returns Local. Otherwise, the name is taken to be a location name corresponding to a file in the IANA Time Zone database, such as "America/New_York". LoadLocation looks for the IANA Time Zone database in the following locations in order: - the directory or uncompressed zip file named by the ZONEINFO environment variable - on a Unix system, t...

    time/zoneinfo.go:663

    func LoadLocationFromTZData(name string, data []byte) (*Location, error)

    LoadLocationFromTZData returns a Location with the given name initialized from the IANA Time Zone database-formatted data. The data should be in the format of a standard IANA time zone file (for example, the content of /etc/localtime on Unix systems).

    time/zoneinfo_read.go:118

    func NewTicker(d Duration) *Ticker

    NewTicker returns a new [Ticker] containing a channel that will send the current time on the channel after each tick. The period of the ticks is specified by the duration argument. The ticker will adjust the time interval or drop ticks to make up for slow receivers. The duration d must be greater than zero; if not, NewTicker will panic. Before Go 1.23, the garbage collector did not recover tickers that had not yet expired or been stopped, so code often immediately deferred t.Stop after calli...

    time/tick.go:36

    func NewTimer(d Duration) *Timer

    NewTimer creates a new Timer that will send the current time on its channel after at least duration d. Before Go 1.23, the garbage collector did not recover timers that had not yet expired or been stopped, so code often immediately deferred t.Stop after calling NewTimer, to make the timer recoverable when it was no longer needed. As of Go 1.23, the garbage collector can recover unreferenced timers, even if they haven't expired or been stopped. The Stop method is no longer necessary to help t...

    time/sleep.go:143

    func Now() Time

    Now returns the current local time.

    time/time.go:1347

    func Parse(layout string, value string) (Time, error)

    Parse parses a formatted string and returns the time value it represents. See the documentation for the constant called [Layout] to see how to represent the format. The second argument must be parseable using the format string (layout) provided as the first argument. The example for [Time.Format] demonstrates the working of the layout string in detail and is a good reference. When parsing (only), the input may contain a fractional second field immediately after the seconds field, even if th...

    time/format.go:1023

    func ParseDuration(s string) (Duration, error)

    ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".

    time/format.go:1631

    func ParseInLocation(layout string, value string, loc *Location) (Time, error)

    ParseInLocation is like Parse but differs in two important ways. First, in the absence of time zone information, Parse interprets a time as UTC; ParseInLocation interprets the time as in the given location. Second, when given a zone offset or abbreviation, Parse tries to match it against the Local location; ParseInLocation uses the given location.

    time/format.go:1038

    func Since(t Time) Duration

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

    time/time.go:1227

    func Sleep(d Duration)

    Sleep pauses the current goroutine for at least the duration d. A negative or zero duration causes Sleep to return immediately.

    time/sleep.go:14

    func Tick(d Duration) <-chan Time

    Tick is a convenience wrapper for [NewTicker] providing access to the ticking channel only. Unlike NewTicker, Tick will return nil if d <= 0. Before Go 1.23, this documentation warned that the underlying [Ticker] would never be recovered by the garbage collector, and that if efficiency was a concern, code should use NewTicker instead and call [Ticker.Stop] when the ticker is no longer needed. As of Go 1.23, the garbage collector can recover unreferenced tickers, even if they haven't been sto...

    time/tick.go:86

    func Unix(sec int64, nsec int64) Time

    Unix returns the local Time corresponding to the given Unix time, sec seconds and nsec nanoseconds since January 1, 1970 UTC. It is valid to pass nsec outside the range [0, 999999999]. Not all sec values have a corresponding time value. One such value is 1<<63-1 (the largest int64 value).

    time/time.go:1655

    func UnixMicro(usec int64) Time

    UnixMicro returns the local Time corresponding to the given Unix time, usec microseconds since January 1, 1970 UTC.

    time/time.go:1676

    func UnixMilli(msec int64) Time

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

    time/time.go:1670

    func Until(t Time) Duration

    Until returns the duration until t. It is shorthand for t.Sub(time.Now()).

    time/time.go:1237

    Types

    type Duration int64

    A Duration represents the elapsed time between two instants as an int64 nanosecond count. The representation limits the largest representable duration to approximately 290 years.

    time/time.go:915

    func (d Duration) Abs() Duration

    Abs returns the absolute value of d. As a special case, Duration([math.MinInt64]) is converted to Duration([math.MaxInt64]), reducing its magnitude by 1 nanosecond.

    time/time.go:1158

    func (d Duration) Hours() float64

    Hours returns the duration as a floating point number of hours.

    time/time.go:1104

    func (d Duration) Microseconds() int64

    Microseconds returns the duration as an integer microsecond count.

    time/time.go:1075

    func (d Duration) Milliseconds() int64

    Milliseconds returns the duration as an integer millisecond count.

    time/time.go:1078

    func (d Duration) Minutes() float64

    Minutes returns the duration as a floating point number of minutes.

    time/time.go:1097

    func (d Duration) Nanoseconds() int64

    Nanoseconds returns the duration as an integer nanosecond count.

    time/time.go:1072

    func (d Duration) Round(m Duration) Duration

    Round returns the result of rounding d to the nearest multiple of m. The rounding behavior for halfway values is to round away from zero. If the result exceeds the maximum (or minimum) value that can be stored in a [Duration], Round returns the maximum (or minimum) duration. If m <= 0, Round returns d unchanged.

    time/time.go:1131

    func (d Duration) Seconds() float64

    Seconds returns the duration as a floating point number of seconds.

    time/time.go:1090

    func (d Duration) String() string

    String returns a string representing the duration in the form "72h3m0.5s". Leading zero units are omitted. As a special case, durations less than one second format use a smaller unit (milli-, micro-, or nanoseconds) to ensure that the leading digit is non-zero. The zero duration formats as 0s.

    time/time.go:947

    func (d Duration) Truncate(m Duration) Duration

    Truncate returns the result of rounding d toward zero to a multiple of m. If m <= 0, Truncate returns d unchanged.

    time/time.go:1112

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

    A Location maps time instants to the zone in use at that time. Typically, the Location represents the collection of time offsets in use in a geographical area. For many Locations the time offset varies depending on whether daylight savings time is in use at the time instant. Location is used to provide a time zone in a printed Time value and for calculations involving intervals that may cross daylight savings time boundaries.

    time/zoneinfo.go:23

    func (l *Location) String() string

    String returns a descriptive name for the time zone information, corresponding to the name argument to [LoadLocation] or [FixedZone].

    time/zoneinfo.go:103

    type Month int

    A Month specifies a month of the year (January = 1, ...).

    time/time.go:324

    func (m Month) String() string

    String returns the English name of the month ("January", "February", ...).

    time/time.go:342

    type ParseError struct {
    	Layout     string
    	Value      string
    	LayoutElem string
    	ValueElem  string
    	Message    string
    }

    ParseError describes a problem parsing a time string.

    time/format.go:841

    func (e *ParseError) Error() string

    Error returns the string representation of a ParseError.

    time/format.go:902

    type Ticker struct {
    	C <-chan Time // The channel on which the ticks are delivered.
    	// contains filtered or unexported fields
    }

    A Ticker holds a channel that delivers “ticks” of a clock at intervals.

    time/tick.go:16

    func (t *Ticker) Reset(d Duration)

    Reset stops a ticker and resets its period to the specified duration. The next tick will arrive after the new period elapses. The duration d must be greater than zero; if not, Reset will panic.

    time/tick.go:65

    func (t *Ticker) Stop()

    Stop turns off a ticker. After Stop, no more ticks will be sent. Stop does not close the channel, to prevent a concurrent goroutine reading from the channel from seeing an erroneous "tick".

    time/tick.go:52

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

    A Time represents an instant in time with nanosecond precision. Programs using times should typically store and pass them as values, not pointers. That is, time variables and struct fields should be of type [time.Time], not *time.Time. A Time value can be used by multiple goroutines simultaneously except that the methods [Time.GobDecode], [Time.UnmarshalBinary], [Time.UnmarshalJSON] and [Time.UnmarshalText] are not concurrency-safe. Time instants can be compared using the [Time.Before], [T...

    time/time.go:140

    func (t Time) Add(d Duration) Time

    Add returns the time t+d.

    time/time.go:1170

    func (t Time) AddDate(years int, months int, days int) Time

    AddDate returns the time corresponding to adding the given number of years, months, and days to t. For example, AddDate(-1, 2, 3) applied to January 1, 2011 returns March 4, 2010. Note that dates are fundamentally coupled to timezones, and calendrical periods like days don't have fixed durations. AddDate uses the Location of the Time value to determine these durations. That means that the same AddDate arguments can produce a different shift in absolute time depending on the base Time value a...

    time/time.go:1262

    func (t Time) After(u Time) bool

    After reports whether the time instant t is after u.

    time/time.go:271

    func (t Time) AppendBinary(b []byte) ([]byte, error)

    AppendBinary implements the [encoding.BinaryAppender] interface.

    time/time.go:1470

    func (t Time) AppendFormat(b []byte, layout string) []byte

    AppendFormat is like [Time.Format] but appends the textual representation to b and returns the extended buffer.

    time/format.go:655

    func (t Time) AppendText(b []byte) ([]byte, error)

    AppendText implements the [encoding.TextAppender] interface. The time is formatted in RFC 3339 format with sub-second precision. If the timestamp cannot be represented as valid RFC 3339 (e.g., the year is out of range), then an error is returned.

    time/time.go:1630

    func (t Time) Before(u Time) bool

    Before reports whether the time instant t is before u.

    time/time.go:281

    func (t Time) Clock() int

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

    time/time.go:870

    func (t Time) Compare(u Time) int

    Compare compares the time instant t with u. If t is before u, it returns -1; if t is after u, it returns +1; if they're the same, it returns 0.

    time/time.go:292

    func (t Time) Date() (int, Month, int)

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

    time/time.go:812

    func (t Time) Day() int

    Day returns the day of the month specified by t.

    time/time.go:831

    func (t Time) Equal(u Time) 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 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.

    time/time.go:316

    func (t Time) Format(layout string) string

    Format returns a textual representation of the time value formatted according to the layout defined by the argument. See the documentation for the constant called [Layout] to see how to represent the layout format. The executable example for [Time.Format] demonstrates the working of the layout string in detail and is a good reference.

    time/format.go:639

    func (t *Time) GobDecode(data []byte) error

    GobDecode implements the gob.GobDecoder interface.

    time/time.go:1583

    func (t Time) GobEncode() ([]byte, error)

    GobEncode implements the gob.GobEncoder interface.

    time/time.go:1578

    func (t Time) GoString() string

    GoString implements [fmt.GoStringer] and formats t to be printed in Go source code.

    time/format.go:577

    func (t Time) Hour() int

    Hour returns the hour within the day specified by t, in the range [0, 23].

    time/time.go:885

    func (t Time) In(loc *Location) Time

    In returns a copy of t representing the same time instant, but with the copy's location information set to loc for display purposes. In panics if loc is nil.

    time/time.go:1384

    func (t Time) IsDST() bool

    IsDST reports whether the time in the configured location is in Daylight Savings Time.

    time/time.go:1681

    func (t Time) ISOWeek() int

    ISOWeek returns the ISO 8601 year and week number in which t occurs. Week ranges from 1 to 53. Jan 01 to Jan 03 of year n might belong to week 52 or 53 of year n-1, and Dec 29 to Dec 31 might belong to week 1 of year n+1.

    time/time.go:852

    func (t Time) IsZero() bool

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

    time/time.go:262

    func (t Time) Local() Time

    Local returns t with the location set to local time.

    time/time.go:1374

    func (t Time) Location() *Location

    Location returns the time zone information associated with t.

    time/time.go:1393

    func (t Time) MarshalBinary() ([]byte, error)

    MarshalBinary implements the [encoding.BinaryMarshaler] interface.

    time/time.go:1517

    func (t Time) MarshalJSON() ([]byte, error)

    MarshalJSON implements the [encoding/json.Marshaler] interface. The time is a quoted string in the RFC 3339 format with sub-second precision. If the timestamp cannot be represented as valid RFC 3339 (e.g., the year is out of range), then an error is reported.

    time/time.go:1591

    func (t Time) MarshalText() ([]byte, error)

    MarshalText implements the [encoding.TextMarshaler] interface. The output matches that of calling the [Time.AppendText] method. See [Time.AppendText] for more information.

    time/time.go:1638

    func (t Time) Minute() int

    Minute returns the minute offset within the hour specified by t, in the range [0, 59].

    time/time.go:890

    func (t Time) Month() Month

    Month returns the month of the year specified by t.

    time/time.go:824

    func (t Time) Nanosecond() int

    Nanosecond returns the nanosecond offset within the second specified by t, in the range [0, 999999999].

    time/time.go:901

    func (t Time) Round(d Duration) Time

    Round returns the result of rounding t to the nearest multiple of d (since the zero time). The rounding behavior for halfway values is to round up. If d <= 0, Round returns t stripped of any monotonic clock reading but otherwise unchanged. Round operates on the time as an absolute duration since the zero time; it does not operate on the presentation form of the time. Thus, Round(Hour) may return a time with a non-zero minute, depending on the time's Location.

    time/time.go:1799

    func (t Time) Second() int

    Second returns the second offset within the minute specified by t, in the range [0, 59].

    time/time.go:895

    func (t Time) String() string

    String returns the time formatted using the format string "2006-01-02 15:04:05.999999999 -0700 MST" If the time has a monotonic clock reading, the returned string includes a final field "m=±<value>", where value is the monotonic clock reading formatted as a decimal number of seconds. The returned string is meant for debugging; for a stable serialized representation, use t.MarshalText, t.MarshalBinary, or t.Format with an explicit format string.

    time/format.go:546

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

    time/time.go:1198

    func (t Time) Truncate(d Duration) Time

    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.

    time/time.go:1782

    func (t Time) Unix() int64

    Unix returns t as a Unix time, the number of seconds elapsed since January 1, 1970 UTC. The result does not depend on the location associated with t. Unix-like operating systems often record time as a 32-bit count of seconds, but since the method here returns a 64-bit value it is valid for billions of years into the past or future.

    time/time.go:1432

    func (t Time) UnixMicro() int64

    UnixMicro returns t as a Unix time, the number of microseconds elapsed since January 1, 1970 UTC. The result is undefined if the Unix time in microseconds cannot be represented by an int64 (a date before year -290307 or after year 294246). The result does not depend on the location associated with t.

    time/time.go:1450

    func (t Time) UnixMilli() int64

    UnixMilli returns t as a Unix time, the number of milliseconds elapsed since January 1, 1970 UTC. The result is undefined if the Unix time in milliseconds cannot be represented by an int64 (a date more than 292 million years before or after 1970). The result does not depend on the location associated with t.

    time/time.go:1441

    func (t Time) UnixNano() int64

    UnixNano returns t as a Unix time, the number of nanoseconds elapsed since January 1, 1970 UTC. The result is undefined if the Unix time in nanoseconds cannot be represented by an int64 (a date before the year 1678 or after 2262). Note that this means the result of calling UnixNano on the zero Time is undefined. The result does not depend on the location associated with t.

    time/time.go:1460

    func (t *Time) UnmarshalBinary(data []byte) error

    UnmarshalBinary implements the [encoding.BinaryUnmarshaler] interface.

    time/time.go:1526

    func (t *Time) UnmarshalJSON(data []byte) error

    UnmarshalJSON implements the [encoding/json.Unmarshaler] interface. The time must be a quoted string in the RFC 3339 format.

    time/time.go:1604

    func (t *Time) UnmarshalText(data []byte) error

    UnmarshalText implements the [encoding.TextUnmarshaler] interface. The time must be in the RFC 3339 format.

    time/time.go:1644

    func (t Time) UTC() Time

    UTC returns t with the location set to UTC.

    time/time.go:1368

    func (t Time) Weekday() Weekday

    Weekday returns the day of the week specified by t.

    time/time.go:838

    func (t Time) Year() int

    Year returns the year in which t occurs.

    time/time.go:817

    func (t Time) YearDay() int

    YearDay returns the day of the year specified by t, in the range [1,365] for non-leap years, and [1,366] in leap years.

    time/time.go:907

    func (t Time) Zone() (string, int)

    Zone computes the time zone in effect at time t, returning the abbreviated name of the zone (such as "CET") and its offset in seconds east of UTC.

    time/time.go:1403

    func (t Time) ZoneBounds() Time

    ZoneBounds returns the bounds of the time zone in effect at time t. The zone begins at start and the next zone begins at end. If the zone begins at the beginning of time, start will be returned as a zero Time. If the zone goes on forever, end will be returned as a zero Time. The Location of the returned times will be the same as t.

    time/time.go:1413

    type Timer struct {
    	C <-chan Time
    	// contains filtered or unexported fields
    }

    The Timer type represents a single event. When the Timer expires, the current time will be sent on C, unless the Timer was created by [AfterFunc]. A Timer must be created with [NewTimer] or AfterFunc.

    time/sleep.go:89

    func (t *Timer) Reset(d Duration) bool

    Reset changes the timer to expire after duration d. It returns true if the timer had been active, false if the timer had expired or been stopped. For a func-based timer created with [AfterFunc](d, f), Reset either reschedules when f will run, in which case Reset returns true, or schedules f to run again, in which case it returns false. When Reset returns false, Reset neither waits for the prior f to complete before returning nor does it guarantee that the subsequent goroutine running f does ...

    time/sleep.go:171

    func (t *Timer) Stop() bool

    Stop prevents the [Timer] from firing. It returns true if the call stops the timer, false if the timer has already expired or been stopped. For a func-based timer created with [AfterFunc](d, f), if t.Stop returns false, then the timer has already expired and the function f has been started in its own goroutine; Stop does not wait for f to complete before returning. If the caller needs to know whether f is completed, it must coordinate with f explicitly. For a chan-based timer created with N...

    time/sleep.go:113

    type Weekday int

    A Weekday specifies a day of the week (Sunday = 0, ...).

    time/time.go:352

    func (d Weekday) String() string

    String returns the English name of the day ("Sunday", "Monday", ...).

    time/time.go:365