import "time"
Package_unix" )
These are predefined layouts for use in Time.Format and time.Parse. The reference time used in the layouts is the specific time:
Mon Jan 2 15:04:05 MST 2006
which is Unix time 1136239445. Since MST is GMT-0700, the reference time can be thought of as
01/02 03:04:05PM '06 -0700
To define your own format, write down what the reference time would look like formatted your way; see the values of constants like ANSIC, StampMicro or Kitchen for examples. The model is to demonstrate what the reference time looks like so that the Format and Parse methods can apply the same transformation to a general time value.
Some valid layouts are invalid time values for time.Parse, due to formats such as _ for space padding and Z for zone information.
Within the format string, an underscore _ represents a space that may be replaced by a digit if the following number (a day) has two digits; for compatibility with fixed-width Unix time formats.
A decimal point followed by one or more zeros represents a fractional second, printed to the given number of decimal places. A decimal point followed by one or more nines represents a fractional second, printed to the given number of decimal places, with trailing zeros removed. When parsing (only), the input may contain a fractional second field immediately after the seconds field, even if the layout does not signify its presence. In that case a decimal point followed by a maximal series of digits is parsed as a fractional second.
Numeric time zone offsets format as follows:
-0700 ±hhmm -07:00 ±hh:mm -07 ±hh
Replacing the sign in the format with a Z triggers the ISO 8601 behavior of printing Z instead of an offset for the UTC zone. Thus:
Z0700 Z or ±hhmm Z07:00 Z or ±hh:mm Z07 Z or ±hh
The recognized day of week formats are "Mon" and "Monday". The recognized month formats are "Jan" and "January".
The formats 2, _2, and 02 are unpadded, space-padded, and zero-padded day of month. The formats __2 and 002 are space-padded and zero-padded three-character day of year; there is no unpadded day of year format. and they do accept time formats not formally defined..
Sleep pauses the current goroutine for at least the duration d. A negative or zero duration causes Sleep to return immediately..
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.
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".:
10h0m0s 1h10m10s There are 4210 seconds in 1h10m10s. There are 1000 nanoseconds in 1µs. There are 1.00e-06 seconds in 1µs.
Since returns the time elapsed since t. It is shorthand for time.Now().Sub(t).
Until returns the duration until t. It is shorthand for t.Sub(time.Now()).
Hours returns the duration as a floating point number of hours.
Microseconds returns the duration as an integer microsecond count.
Milliseconds returns the duration as an integer millisecond count.
Minutes returns the duration as a floating point number of minutes.
Nanoseconds returns the duration as an integer nanosecond count..
Seconds returns the duration as a floating point number of seconds..
Truncate returns the result of rounding d toward zero to a multiple of m. If m <= 0, Truncate returns d unchanged.. For many Locations the time offset varies depending on whether daylight savings time is in use at the time instant.
Local represents the system's local time zone. On Unix systems, Local consults the TZ environment variable to find the time zone to use. No TZ means use the system default /etc/localtime. TZ="" means use UTC. TZ="foo" means use file foo in the system timezone directory.
UTC represents Universal Coordinated Time (UTC).
//
FixedZone returns a Location that always uses the given zone name and offset (seconds east of UTC).".
The time zone database needed by LoadLocation may not be present on all systems, especially non-Unix systems. LoadLocation looks in the directory or uncompressed zip file named by the ZONEINFO environment variable, if any, then looks in known installation locations on Unix systems, and finally looks in $GOROOT/lib/time/zoneinfo.zip.
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).
String returns a descriptive name for the time zone information, corresponding to the name argument to LoadLocation or FixedZone.
A Month specifies a month of the year (January = 1, ...).
const ( January Month = 1 + iota February March April May June July August September October November December ).
Reset stops a ticker and resets its period to the specified duration. The next tick will arrive after the new period elapses..
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..
Now returns the current local time..
For layouts specifying the two-digit year 06, a value NN >= 69 will be treated as 19NN and a value NN < 69 will be treated as 20NN.).
Add returns the time t+d.
After reports whether the time instant t is after u.
AppendFormat is like Format but appends the textual representation to b and returns the extended buffer.
Before reports whether the time instant t is before u.
Clock returns the hour, minute, and second within the day specified by t.
Date returns the year, month, and day in which t occurs.
Day returns the day of the month specified by t.
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"
GobDecode implements the gob.GobDecoder interface.
GobEncode implements the gob.GobEncoder interface.
Hour returns the hour within the day specified by t, in the range [0, 23]..
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.
IsZero reports whether t represents the zero time instant, January 1, year 1, 00:00:00 UTC.
Local returns t with the location set to local time.
Location returns the time zone information associated with t.
MarshalBinary implements the encoding.BinaryMarshaler interface.
MarshalJSON implements the json.Marshaler interface. The time is a quoted string in RFC 3339 format, with sub-second precision added if present.
MarshalText implements the encoding.TextMarshaler interface. The time is formatted in RFC 3339 format, with sub-second precision added if present.
Minute returns the minute offset within the hour specified by t, in the range [0, 59].
Month returns the month of the year specified by t.
Nanosecond returns the nanosecond offset within the second specified by t, in the range [0, 999999999].
Second returns the second offset within the minute specified by t, in the range [0, 59].
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).
UTC returns t with the location set to UTC.
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.
//.
UnmarshalBinary implements the encoding.BinaryUnmarshaler interface.
UnmarshalJSON implements the json.Unmarshaler interface. The time is expected to be a quoted string in RFC 3339 format.
UnmarshalText implements the encoding.TextUnmarshaler interface. The time is expected to be in RFC 3339 format.
Weekday returns the day of the week specified by t.
Year returns the year in which t occurs.
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.
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.
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.
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.
NewTimer creates a new Timer that will send the current time on its channel after at least duration d.
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.
Reset should be invoked only on stopped or expired timers with drained channels. If a program has already received a value from t.C, the timer is known to have expired and the channel drained, so.
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. Stop does not close the channel, to prevent a read from the channel succeeding incorrectly.
To ensure the channel is empty after a call to Stop, check the return value and drain the channel. For example, assuming the program has not received from t.C already:
if !t.Stop() { <-t.C }
This cannot be done concurrent to other receives from the Timer's channel or other calls to the Timer's Stop method..
A Weekday specifies a day of the week (Sunday = 0, ...).
String returns the English name of the day ("Sunday", "Monday", ...).
Package time imports 5 packages (graph) and is imported by 494912 packages. Updated 2020-09-14. Refresh now. Tools for package owners.