[#absl-Time]
= xref:absl.adoc[absl]::Time
:relfileprefix: ../
:mrdocs:

An `absl&colon;&colon;Time` represents a specific instant in time&period; Arithmetic operators are provided for naturally expressing time calculations&period; Instances are created using `absl&colon;&colon;Now()` and the `absl&colon;&colon;From&ast;()` factory functions that accept the gamut of other time representations&period; Formatting and parsing functions are provided for conversion to and from strings&period; `absl&colon;&colon;Time` is trivially destructible and should be passed by value rather than const reference&period;

== Synopsis

Declared in `&lt;absl&sol;time&sol;time&period;h&gt;`

[source,cpp,subs="verbatim,replacements,macros,-callouts"]
----
class Time;
----

== Description

`absl&colon;&colon;Time` assumes there are 60 seconds in a minute, which means the underlying time scales must be &quot;smeared&quot; to eliminate leap seconds&period; See https&colon;&sol;&sol;developers&period;google&period;com&sol;time&sol;smear&period;

Even though `absl&colon;&colon;Time` supports a wide range of timestamps, exercise caution when using values in the distant past&period; `absl&colon;&colon;Time` uses the Proleptic Gregorian calendar, which extends the Gregorian calendar backward to dates before its introduction in 1582&period; See https&colon;&sol;&sol;en&period;wikipedia&period;org&sol;wiki&sol;Proleptic&lowbar;Gregorian&lowbar;calendar for more information&period; Use the ICU calendar classes to convert a date in some other calendar (http&colon;&sol;&sol;userguide&period;icu&hyphen;project&period;org&sol;datetime&sol;calendar)&period;

Similarly, standardized time zones are a reasonably recent innovation, with the Greenwich prime meridian being established in 1884&period; The TZ database itself does not profess accurate offsets for timestamps prior to 1970&period; The breakdown of future timestamps is subject to the whim of regional governments&period;

The `absl&colon;&colon;Time` class represents an instant in time as a count of clock ticks of some granularity (resolution) from some starting point (epoch)&period;

`absl&colon;&colon;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&period;e&period;, resolution of at least one nanosecond, and range &plus;&sol;&hyphen;100 billion years)&period; Conversions between the time scales are performed by truncating (towards negative infinity) to the nearest representable point&period;

Examples&colon;

absl&colon;&colon;Time t1 &equals; &period;&period;&period;&semi; absl&colon;&colon;Time t2 &equals; t1 &plus; absl&colon;&colon;Minutes(2)&semi; absl&colon;&colon;Duration d &equals; t2 &hyphen; t1&semi; &sol;&sol; &equals;&equals; absl&colon;&colon;Minutes(2)

== Types

[cols="1,4"]
|===
| Name| Description
| xref:absl/Time/Breakdown.adoc[`Breakdown`]  [.small]#[deprecated]#
| The calendar and wall&hyphen;clock (aka &quot;civil time&quot;) components of an `absl&colon;&colon;Time` in a certain `absl&colon;&colon;TimeZone`&period; This struct is not intended to represent an instant in time&period; So, rather than passing a `Time&colon;&colon;Breakdown` to a function, pass an `absl&colon;&colon;Time` and an `absl&colon;&colon;TimeZone`&period;
|===


== Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/Time/2constructor-0b.adoc[`Time`]         [.small]#[constructor]#
| Constructors
| xref:absl/Time/operator_assign.adoc[`operator&equals;`] 
| Assigns a copy of another time&period;
| xref:absl/Time/In.adoc[`In`]  [.small]#[deprecated]#
| Returns the breakdown of this instant in the given TimeZone&period;
| xref:absl/Time/operator_plus_eq.adoc[`operator&plus;&equals;`] 
| Advances this time by a duration&period;
| xref:absl/Time/operator_minus_eq.adoc[`operator&hyphen;&equals;`] 
| Moves this time back by a duration&period;
|===


== Friends

[cols="1,4"]
|===
| Name| Description
| `xref:absl/InfinitePast.adoc[absl::InfinitePast]`
| Returns an `absl&colon;&colon;Time` that is infinitely far in the past&period;
| `xref:absl/InfiniteFuture.adoc[absl::InfiniteFuture]`
| Returns an `absl&colon;&colon;Time` that is infinitely far in the future&period;
| `xref:absl/UniversalEpoch.adoc[absl::UniversalEpoch]`
| Returns the `absl&colon;&colon;Time` representing the ICU Universal Time Scale epoch&period;
| `xref:absl/operator_minus-0b.adoc[absl::operator&hyphen;]`
| Returns the duration between two times&period;
| `xref:absl/operator_eq-08d3.adoc[absl::operator&equals;&equals;]`
| Returns whether two times are equal&period;
| `xref:absl/operator_lt-0e7.adoc[absl::operator&lt;]`
| Returns whether one time is earlier than another&period;
| `xref:absl/operator_3way-0d.adoc[absl::operator&lt;&equals;&gt;]`
| Three&hyphen;way&hyphen;compares two times&period;
| `xref:absl/AbslHashValue-0f3.adoc[absl::AbslHashValue]`
| Combines this time into a hash state&period;
|===

== Non-Member Functions

[cols="1,4"]
|===
| Name| Description
| xref:absl/AbslUnparseFlag-03.adoc[`AbslUnparseFlag`]
| Unparses a Time value into a command&hyphen;line string representation using the format specified by `absl&colon;&colon;ParseTime()`&period;
| xref:absl/FormatTime-01.adoc[`FormatTime`]
| Formats the given time using the RFC3339&lowbar;full format in the given time zone&period;
| xref:absl/FormatTime-0a.adoc[`FormatTime`]
| Formats the given time using the RFC3339&lowbar;full format in the local time zone&period;
| xref:absl/FromChrono-0d6.adoc[`FromChrono`]
| Converts a std&colon;&colon;chrono&colon;&colon;system&lowbar;clock&colon;&colon;time&lowbar;point to an absl&colon;&colon;Time&period;
| xref:absl/FromCivil.adoc[`FromCivil`]
| Helper for TimeZone&colon;&colon;At(CivilSecond) that provides &quot;order&hyphen;preserving semantics&period;&quot; If the civil time maps to a unique time, that time is returned&period; If the civil time is repeated in the given time zone, the time using the pre&hyphen;transition offset is returned&period; Otherwise, the civil time is skipped in the given time zone, and the transition time is returned&period; This means that for any two civil times, ct1 and ct2, (ct1 &lt; ct2) &equals;&gt; (FromCivil(ct1) &lt;&equals; FromCivil(ct2)), the equal case being when two non&hyphen;existent civil times map to the same transition time&period;
| xref:absl/FromDateTime.adoc[`FromDateTime`]
| A convenience wrapper for `absl&colon;&colon;ConvertDateTime()` that simply returns the &quot;pre&quot; `absl&colon;&colon;Time`&period; That is, the unique result, or the instant that is correct using the pre&hyphen;transition offset (as if the transition never happened)&period;
| xref:absl/FromTM.adoc[`FromTM`]
| Converts the `tm&lowbar;year`, `tm&lowbar;mon`, `tm&lowbar;mday`, `tm&lowbar;hour`, `tm&lowbar;min`, and `tm&lowbar;sec` fields to an `absl&colon;&colon;Time` using the given time zone&period; See ctime(3) for a description of the expected values of the tm fields&period; If the civil time is unique (see `absl&colon;&colon;TimeZone&colon;&colon;At(absl&colon;&colon;CivilSecond)` above), the matching time instant is returned&period; Otherwise, the `tm&lowbar;isdst` field is consulted to choose between the possible results&period; For a repeated civil time, &grave;tm&lowbar;isdst !&equals; 0` returns the matching DST instant, while `tm&lowbar;isdst &equals;&equals; 0&grave; returns the matching non&hyphen;DST instant&period; For a skipped civil time there is no matching instant, so `tm&lowbar;isdst !&equals; 0` returns the DST instant, and `tm&lowbar;isdst &equals;&equals; 0` returns the non&hyphen;DST instant, that would have matched if the transition never happened&period;
| xref:absl/FromTimeT.adoc[`FromTimeT`]
| Creates an `absl&colon;&colon;Time` from a `time&lowbar;t` value&period;
| xref:absl/FromUDate.adoc[`FromUDate`]
| Creates an `absl&colon;&colon;Time` from an ICU UDate value&period;
| xref:absl/FromUniversal.adoc[`FromUniversal`]
| Creates an `absl&colon;&colon;Time` from an ICU Universal Time Scale value&period;
| xref:absl/FromUnixMicros.adoc[`FromUnixMicros`]
| Creates an `absl&colon;&colon;Time` from a count of microseconds since the Unix epoch&period;
| xref:absl/FromUnixMillis.adoc[`FromUnixMillis`]
| Creates an `absl&colon;&colon;Time` from a count of milliseconds since the Unix epoch&period;
| xref:absl/FromUnixNanos.adoc[`FromUnixNanos`]
| Creates an `absl&colon;&colon;Time` from a count of nanoseconds since the Unix epoch&period;
| xref:absl/FromUnixSeconds.adoc[`FromUnixSeconds`]
| Creates an `absl&colon;&colon;Time` from a count of seconds since the Unix epoch&period;
| xref:absl/Now.adoc[`Now`]
| Returns the current time, expressed as an `absl&colon;&colon;Time` absolute time value&period;
| xref:absl/TimeFromTimespec.adoc[`TimeFromTimespec`]
| Converts a `timespec` to an `absl&colon;&colon;Time`&period;
| xref:absl/TimeFromTimeval.adoc[`TimeFromTimeval`]
| Converts a `timeval` to an `absl&colon;&colon;Time`&period;
| xref:absl/ToChronoTime.adoc[`ToChronoTime`]
| Converts an absl&colon;&colon;Time to a std&colon;&colon;chrono&colon;&colon;system&lowbar;clock&colon;&colon;time&lowbar;point&period; If overflow would occur, the returned value will saturate at the min&sol;max time point value instead&period;
| xref:absl/ToCivilDay.adoc[`ToCivilDay`]
| Converts an absolute time to a day&hyphen;aligned civil time in a time zone&period;
| xref:absl/ToCivilHour.adoc[`ToCivilHour`]
| Converts an absolute time to an hour&hyphen;aligned civil time in a time zone&period;
| xref:absl/ToCivilMinute.adoc[`ToCivilMinute`]
| Converts an absolute time to a minute&hyphen;aligned civil time in a time zone&period;
| xref:absl/ToCivilMonth.adoc[`ToCivilMonth`]
| Converts an absolute time to a month&hyphen;aligned civil time in a time zone&period;
| xref:absl/ToCivilSecond.adoc[`ToCivilSecond`]
| Converts an absolute time to a second&hyphen;aligned civil time in a time zone&period;
| xref:absl/ToCivilYear.adoc[`ToCivilYear`]
| Converts an absolute time to a year&hyphen;aligned civil time in a time zone&period;
| xref:absl/ToTM.adoc[`ToTM`]
| Converts the given `absl&colon;&colon;Time` to a struct tm using the given time zone&period; See ctime(3) for a description of the values of the tm fields&period;
| xref:absl/ToTimeT.adoc[`ToTimeT`]
| Converts an `absl&colon;&colon;Time` to a `time&lowbar;t` value&period;
| xref:absl/ToTimespec-09.adoc[`ToTimespec`]
| Converts an `absl&colon;&colon;Time` to a `timespec`&period;
| xref:absl/ToTimeval-0d.adoc[`ToTimeval`]
| Converts an `absl&colon;&colon;Time` to a `timeval`&period;
| xref:absl/ToUDate.adoc[`ToUDate`]
| Converts an `absl&colon;&colon;Time` to an ICU UDate value&period;
| xref:absl/ToUniversal.adoc[`ToUniversal`]
| Converts an `absl&colon;&colon;Time` to an ICU Universal Time Scale value&period;
| xref:absl/ToUnixMicros.adoc[`ToUnixMicros`]
| Converts an `absl&colon;&colon;Time` to a count of microseconds since the Unix epoch&period;
| xref:absl/ToUnixMillis.adoc[`ToUnixMillis`]
| Converts an `absl&colon;&colon;Time` to a count of milliseconds since the Unix epoch&period;
| xref:absl/ToUnixNanos.adoc[`ToUnixNanos`]
| Converts an `absl&colon;&colon;Time` to a count of nanoseconds since the Unix epoch&period;
| xref:absl/ToUnixSeconds.adoc[`ToUnixSeconds`]
| Converts an `absl&colon;&colon;Time` to a count of seconds since the Unix epoch&period;
| xref:absl/UnixEpoch.adoc[`UnixEpoch`]
| Returns the `absl&colon;&colon;Time` representing &quot;1970&hyphen;01&hyphen;01 00&colon;00&colon;00&period;0 &plus;0000&quot;&period;
| xref:absl/operator_not_eq-052.adoc[`operator!&equals;`]
| Returns whether two times are unequal&period;
| xref:absl/operator_plus-04.adoc[`operator&plus;`]
| Returns the time obtained by advancing a time by a duration&period;
| xref:absl/operator_plus-0b.adoc[`operator&plus;`]
| Returns the time obtained by advancing a time by a duration&period;
| xref:absl/operator_minus-0ea.adoc[`operator&hyphen;`]
| Returns the time obtained by moving a time back by a duration&period;
| xref:absl/operator_le-090.adoc[`operator&lt;&equals;`]
| Returns whether one time is earlier than or equal to another&period;
| xref:absl/operator_gt-0e.adoc[`operator&gt;`]
| Returns whether one time is later than another&period;
| xref:absl/operator_ge-00.adoc[`operator&gt;&equals;`]
| Returns whether one time is later than or equal to another&period;
|===


[.small]#Created with https://www.mrdocs.com[MrDocs]#
