Export of internal Abseil changes.
-- f4e870453d02106c2685e0461816469a4704ad25 by Abseil Team <absl-team@google.com>: Expose TimeZone::NextTransition() and PrevTransition() now that we have absl::CivilSecond support in time.h. Note that these are for informational purposes only. General time code should not care when offset changes occur. PiperOrigin-RevId: 217177292 -- cfadd275c7333f7c27c4d682b9d167010d874e69 by Abseil Team <absl-team@google.com>: Import of CCTZ from GitHub. PiperOrigin-RevId: 217153577 -- 6ff5b8c61a1239b9c0478a7c62bcd2844b310307 by Jon Cohen <cohenjon@google.com>: Fix code examples in hash_testing.h. Includes random clang-format changes. PiperOrigin-RevId: 216898995 -- de124129d27f4627dabe193a10bf106a11783fba by Shaindel Schwartz <shaindel@google.com>: Add contribution guidelines describing how we decide whether to include an API in Abseil. PiperOrigin-RevId: 216886943 GitOrigin-RevId: f4e870453d02106c2685e0461816469a4704ad25 Change-Id: Ib9c6706f5bf931b71c0357bf1342053a3bee8ff7
This commit is contained in:
parent
a00bdd176d
commit
5b70a8910b
6 changed files with 193 additions and 19 deletions
|
@ -176,6 +176,20 @@ inline int MapWeekday(const cctz::weekday& wd) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
bool FindTransition(const cctz::time_zone& tz,
|
||||
bool (cctz::time_zone::*find_transition)(
|
||||
const cctz::time_point<cctz::seconds>& tp,
|
||||
cctz::time_zone::civil_transition* trans) const,
|
||||
Time t, TimeZone::CivilTransition* trans) {
|
||||
// Transitions are second-aligned, so we can discard any fractional part.
|
||||
const auto tp = unix_epoch() + cctz::seconds(ToUnixSeconds(t));
|
||||
cctz::time_zone::civil_transition tr;
|
||||
if (!(tz.*find_transition)(tp, &tr)) return false;
|
||||
trans->from = CivilSecond(tr.from);
|
||||
trans->to = CivilSecond(tr.to);
|
||||
return true;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
//
|
||||
|
@ -366,6 +380,14 @@ absl::TimeZone::TimeInfo TimeZone::At(CivilSecond ct) const {
|
|||
return ti;
|
||||
}
|
||||
|
||||
bool TimeZone::NextTransition(Time t, CivilTransition* trans) const {
|
||||
return FindTransition(cz_, &cctz::time_zone::next_transition, t, trans);
|
||||
}
|
||||
|
||||
bool TimeZone::PrevTransition(Time t, CivilTransition* trans) const {
|
||||
return FindTransition(cz_, &cctz::time_zone::prev_transition, t, trans);
|
||||
}
|
||||
|
||||
//
|
||||
// Conversions involving time zones.
|
||||
//
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue