class TimeZone
Defined at line 1060 of file ../../third_party/abseil-cpp/absl/time/time.h
TimeZone
The `absl::TimeZone` is an opaque, small, value-type class representing a
geo-political region within which particular rules are used for converting
between absolute and civil times (see https://git.io/v59Ly). `absl::TimeZone`
values are named using the TZ identifiers from the IANA Time Zone Database,
such as "America/Los_Angeles" or "Australia/Sydney". `absl::TimeZone` values
are created from factory functions such as `absl::LoadTimeZone()`. Note:
strings like "PST" and "EDT" are not valid TZ identifiers. Prefer to pass by
value rather than const reference.
For more on the fundamental concepts of time zones, absolute times, and civil
times, see https://github.com/google/cctz#fundamental-concepts
Examples:
absl::TimeZone utc = absl::UTCTimeZone();
absl::TimeZone pst = absl::FixedTimeZone(-8 * 60 * 60);
absl::TimeZone loc = absl::LocalTimeZone();
absl::TimeZone lax;
if (!absl::LoadTimeZone("America/Los_Angeles",
&lax
)) {
// handle error case
}
See also:
- https://github.com/google/cctz
- https://www.iana.org/time-zones
- https://en.wikipedia.org/wiki/Zoneinfo
Public Methods
CivilInfo At (Time t)
TimeZone::At(Time)
Returns the civil time for this TimeZone at a certain `absl::Time`.
If the input time is infinite, the output civil second will be set to
CivilSecond::max() or min(), and the subsecond will be infinite.
Example:
const auto epoch = lax.At(absl::UnixEpoch());
// epoch.cs == 1969-12-31 16:00:00
// epoch.subsecond == absl::ZeroDuration()
// epoch.offset == -28800
// epoch.is_dst == false
// epoch.abbr == "PST"
TimeInfo At (CivilSecond ct)
TimeZone::At(CivilSecond)
Returns an `absl::TimeInfo` containing the absolute time(s) for this
TimeZone at an `absl::CivilSecond`. When the civil time is skipped or
repeated, returns times calculated using the pre-transition and post-
transition UTC offsets, plus the transition time itself.
Examples:
// A unique civil time
const auto jan01 = lax.At(absl::CivilSecond(2011, 1, 1, 0, 0, 0));
// jan01.kind == TimeZone::TimeInfo::UNIQUE
// jan01.pre is 2011-01-01 00:00:00 -0800
// jan01.trans is 2011-01-01 00:00:00 -0800
// jan01.post is 2011-01-01 00:00:00 -0800
// A Spring DST transition, when there is a gap in civil time
const auto mar13 = lax.At(absl::CivilSecond(2011, 3, 13, 2, 15, 0));
// mar13.kind == TimeZone::TimeInfo::SKIPPED
// mar13.pre is 2011-03-13 03:15:00 -0700
// mar13.trans is 2011-03-13 03:00:00 -0700
// mar13.post is 2011-03-13 01:15:00 -0800
// A Fall DST transition, when civil times are repeated
const auto nov06 = lax.At(absl::CivilSecond(2011, 11, 6, 1, 15, 0));
// nov06.kind == TimeZone::TimeInfo::REPEATED
// nov06.pre is 2011-11-06 01:15:00 -0700
// nov06.trans is 2011-11-06 01:00:00 -0800
// nov06.post is 2011-11-06 01:15:00 -0800
bool NextTransition (Time t, CivilTransition * trans)
bool PrevTransition (Time t, CivilTransition * trans)
void TimeZone (time_internal::cctz::time_zone tz)
Defined at line 1062 of file ../../third_party/abseil-cpp/absl/time/time.h
void TimeZone ()
Defined at line 1063 of file ../../third_party/abseil-cpp/absl/time/time.h
void TimeZone (const TimeZone & )
Copyable.
Defined at line 1066 of file ../../third_party/abseil-cpp/absl/time/time.h
TimeZone & operator= (const TimeZone & )
Defined at line 1067 of file ../../third_party/abseil-cpp/absl/time/time.h
time_internal::cctz::time_zone operator time_zone ()
Defined at line 1069 of file ../../third_party/abseil-cpp/absl/time/time.h
std::string name ()
Defined at line 1071 of file ../../third_party/abseil-cpp/absl/time/time.h
Records
Friends
std::ostream & TimeZone (std::ostream & os, TimeZone tz)
bool TimeZone (TimeZone a, TimeZone b)
bool TimeZone (TimeZone a, TimeZone b)
template <typename H>
H TimeZone (H hTimeZone tz)