An absl::Time represents a specific instant in time. Arithmetic operators are provided for naturally expressing time calculations. Instances are created using absl::Now() and the absl::From*() factory functions that accept the gamut of other time representations. Formatting and parsing functions are provided for conversion to and from strings. absl::Time is trivially destructible and should be passed by value rather than const reference.
Synopsis
Declared in <absl/time/time.h>
class Time;
Description
absl::Time assumes there are 60 seconds in a minute, which means the underlying time scales must be "smeared" to eliminate leap seconds. See https://developers.google.com/time/smear.
Even though absl::Time supports a wide range of timestamps, exercise caution when using values in the distant past. absl::Time uses the Proleptic Gregorian calendar, which extends the Gregorian calendar backward to dates before its introduction in 1582. See https://en.wikipedia.org/wiki/Proleptic_Gregorian_calendar for more information. Use the ICU calendar classes to convert a date in some other calendar (http://userguide.icu‐project.org/datetime/calendar).
Similarly, standardized time zones are a reasonably recent innovation, with the Greenwich prime meridian being established in 1884. The TZ database itself does not profess accurate offsets for timestamps prior to 1970. The breakdown of future timestamps is subject to the whim of regional governments.
The absl::Time class represents an instant in time as a count of clock ticks of some granularity (resolution) from some starting point (epoch).
absl::Time uses a resolution that is high enough to avoid loss in precision, and a range that is wide enough to avoid overflow, when converting between tick counts in most Google time scales (i.e., resolution of at least one nanosecond, and range +/‐100 billion years). Conversions between the time scales are performed by truncating (towards negative infinity) to the nearest representable point.
Examples:
absl::Time t1 = ...; absl::Time t2 = t1 + absl::Minutes(2); absl::Duration d = t2 ‐ t1; // == absl::Minutes(2)
Types
Name |
Description |
|
The calendar and wall‐clock (aka "civil time") components of an |
Member Functions
Friends
Name |
Description |
Returns an |
|
Returns an |
|
Returns the |
|
Returns the duration between two times. |
|
Returns whether two times are equal. |
|
Returns whether one time is earlier than another. |
|
Three‐way‐compares two times. |
|
Combines this time into a hash state. |
Non-Member Functions
Name |
Description |
Unparses a Time value into a command‐line string representation using the format specified by |
|
Formats the given time using the RFC3339_full format in the given time zone. |
|
Formats the given time using the RFC3339_full format in the local time zone. |
|
Converts a std::chrono::system_clock::time_point to an absl::Time. |
|
Helper for TimeZone::At(CivilSecond) that provides "order‐preserving semantics." If the civil time maps to a unique time, that time is returned. If the civil time is repeated in the given time zone, the time using the pre‐transition offset is returned. Otherwise, the civil time is skipped in the given time zone, and the transition time is returned. This means that for any two civil times, ct1 and ct2, (ct1 < ct2) => (FromCivil(ct1) <= FromCivil(ct2)), the equal case being when two non‐existent civil times map to the same transition time. |
|
A convenience wrapper for |
|
Converts the |
|
Creates an |
|
Creates an |
|
Creates an |
|
Creates an |
|
Creates an |
|
Creates an |
|
Creates an |
|
Returns the current time, expressed as an |
|
Converts a |
|
Converts a |
|
Converts an absl::Time to a std::chrono::system_clock::time_point. If overflow would occur, the returned value will saturate at the min/max time point value instead. |
|
Converts an absolute time to a day‐aligned civil time in a time zone. |
|
Converts an absolute time to an hour‐aligned civil time in a time zone. |
|
Converts an absolute time to a minute‐aligned civil time in a time zone. |
|
Converts an absolute time to a month‐aligned civil time in a time zone. |
|
Converts an absolute time to a second‐aligned civil time in a time zone. |
|
Converts an absolute time to a year‐aligned civil time in a time zone. |
|
Converts the given |
|
Converts an |
|
Converts an |
|
Converts an |
|
Converts an |
|
Converts an |
|
Converts an |
|
Converts an |
|
Converts an |
|
Converts an |
|
Returns the |
|
Returns whether two times are unequal. |
|
Returns the time obtained by advancing a time by a duration. |
|
Returns the time obtained by advancing a time by a duration. |
|
Returns the time obtained by moving a time back by a duration. |
|
Returns whether one time is earlier than or equal to another. |
|
Returns whether one time is later than another. |
|
Returns whether one time is later than or equal to another. |
Created with MrDocs