time point class

class Time

The turbo::Time class represents a specific instant in time.

Arithmetic operators are provided for naturally expressing time calculations. Instances are created using turbo::time_now() and the turbo::From*() factory functions that accept the gamut of other time representations. Formatting and parsing functions are provided for conversion to and from strings. turbo::Time should be passed by value rather than const reference.

turbo::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 turbo::Time supports a wide range of timestamps, exercise caution when using values in the distant past. turbo::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 turbo::Time class represents an instant in time as a count of clock ticks of some granularity (resolution) from some starting point (epoch).

turbo::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:

turbo::Time t1 = ...;
turbo::Time t2 = t1 + turbo::minutes(2);
turbo::Duration d = t2 - t1;  // == turbo::minutes(2)

struct Breakdown