Export of internal Abseil changes

--
880e4ea366ff27f2b5b0c2f693f05424a1e47fbf by Derek Mauro <dmauro@google.com>:

Import of CCTZ from GitHub.

PiperOrigin-RevId: 325351285
GitOrigin-RevId: 880e4ea366ff27f2b5b0c2f693f05424a1e47fbf
Change-Id: I9003e713eff7315f4d38ca5c88efe6151bc26ac4
pull/772/head
Abseil Team 4 years ago committed by Derek Mauro
parent f66bc74928
commit f72cc3516a
  1. 6
      absl/time/internal/cctz/src/time_zone_libc.cc
  2. 10
      absl/time/internal/cctz/src/time_zone_lookup_test.cc

@ -153,7 +153,8 @@ std::time_t find_trans(std::time_t lo, std::time_t hi, int offset) {
std::tm tm;
while (lo + 1 != hi) {
const std::time_t mid = lo + (hi - lo) / 2;
if (std::tm* tmp = local_time(&mid, &tm)) {
std::tm* tmp = local_time(&mid, &tm);
if (tmp != nullptr) {
if (tm_gmtoff(*tmp) == offset) {
hi = mid;
} else {
@ -163,7 +164,8 @@ std::time_t find_trans(std::time_t lo, std::time_t hi, int offset) {
// If std::tm cannot hold some result we resort to a linear search,
// ignoring all failed conversions. Slow, but never really happens.
while (++lo != hi) {
if (std::tm* tmp = local_time(&lo, &tm)) {
tmp = local_time(&lo, &tm);
if (tmp != nullptr) {
if (tm_gmtoff(*tmp) == offset) break;
}
}

@ -1004,13 +1004,13 @@ TEST(MakeTime, SysSecondsLimits) {
#if defined(_WIN32) || defined(_WIN64)
// localtime_s() and gmtime_s() don't believe in years outside [1970:3000].
#else
const time_zone utc = LoadZone("libc:UTC");
const time_zone cut = LoadZone("libc:UTC");
const year_t max_tm_year = year_t{std::numeric_limits<int>::max()} + 1900;
tp = convert(civil_second(max_tm_year, 12, 31, 23, 59, 59), utc);
EXPECT_EQ("2147485547-12-31T23:59:59+00:00", format(RFC3339, tp, utc));
tp = convert(civil_second(max_tm_year, 12, 31, 23, 59, 59), cut);
EXPECT_EQ("2147485547-12-31T23:59:59+00:00", format(RFC3339, tp, cut));
const year_t min_tm_year = year_t{std::numeric_limits<int>::min()} + 1900;
tp = convert(civil_second(min_tm_year, 1, 1, 0, 0, 0), utc);
EXPECT_EQ("-2147481748-01-01T00:00:00+00:00", format(RFC3339, tp, utc));
tp = convert(civil_second(min_tm_year, 1, 1, 0, 0, 0), cut);
EXPECT_EQ("-2147481748-01-01T00:00:00+00:00", format(RFC3339, tp, cut));
#endif
}
}

Loading…
Cancel
Save