Crate gostd_time[−][src]
Expand description
Package time provides functionality for measuring and displaying time. The calendrical calculations always assume a Gregorian calendar, with no leap seconds.
zh-cn
time包提供了时间的显示和测量用的函数。日历的计算采用的是公历。Structs
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.
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.
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.
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.
UTC represents Universal Coordinated Time (UTC).
Enums
A Month specifies a month of the year (January = 1, …).
A Weekday specifies a day of the week (Sunday = 0, …).
Constants
Time Format - ANSIC
Time Unit Hour
Time Format - Kitchen
Time Format - Layout
Time Unit Microsecond
Time Unit Millisecond
Time Unit Minute
Time Unit Nanosecond
Time Format - RFC822
Time Format - RFC822Z
Time Format - RFC850
Time Format - RFC1123
Time Format - RFC1123Z
Time Format - RFC3339
Time Format - RFC3339Nano
Time Format - RubyDate
Time Unit Second
Handy time stamps.
Handy time StampMicro.
Handy time StampMilli.
Handy time StampNano.
Time Format - UnixDate
Functions
Date returns the Time corresponding to
FixedZone returns a Location that always uses the given zone name and offset (seconds east of UTC).
Now returns the current local time.
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.
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”.
Since returns the time elapsed since t. It is shorthand for time.Now().Sub(t).
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).
UnixMicro returns the local Time corresponding to the given Unix time, usec microseconds since January 1, 1970 UTC.
UnixMilli returns the local Time corresponding to the given Unix time, msec milliseconds since January 1, 1970 UTC.
Until returns the duration until t. It is shorthand for t.Sub(time.Now()).