aboutsummaryrefslogtreecommitdiffhomepage
path: root/absl/time/internal/cctz/src/time_zone_format_test.cc
diff options
context:
space:
mode:
authorGravatar Abseil Team <absl-team@google.com>2018-06-29 14:00:35 -0700
committerGravatar Titus Winters <titus@google.com>2018-07-02 09:58:35 -0400
commit134496a31d8b324f762de3bee9a002658c984456 (patch)
treeeb3d81ec6bb667c8f360e6898411a275a19f46c5 /absl/time/internal/cctz/src/time_zone_format_test.cc
parentba8d6cf07766263723e86736f20a51c1c9c67b19 (diff)
Export of internal Abseil changes.
-- aa9e2bff92652605b8244677058be787c872f99c by Abseil Team <absl-team@google.com>: Import of CCTZ from GitHub. PiperOrigin-RevId: 202702969 -- d26c857c203589892a84bc44d789f2a15a60f234 by Abseil Team <absl-team@google.com>: Cleans up the FixedArray code (formatting, renames, etc) without changing the functionality PiperOrigin-RevId: 202538159 GitOrigin-RevId: aa9e2bff92652605b8244677058be787c872f99c Change-Id: I6561257232c6cc8e1cbf51d7e26bae5f8760551e
Diffstat (limited to 'absl/time/internal/cctz/src/time_zone_format_test.cc')
-rw-r--r--absl/time/internal/cctz/src/time_zone_format_test.cc25
1 files changed, 17 insertions, 8 deletions
diff --git a/absl/time/internal/cctz/src/time_zone_format_test.cc b/absl/time/internal/cctz/src/time_zone_format_test.cc
index 33c2398..a90dda7 100644
--- a/absl/time/internal/cctz/src/time_zone_format_test.cc
+++ b/absl/time/internal/cctz/src/time_zone_format_test.cc
@@ -64,6 +64,17 @@ void TestFormatSpecifier(time_point<D> tp, time_zone tz, const std::string& fmt,
EXPECT_EQ("xxx " + ans + " yyy", format("xxx " + fmt + " yyy", tp, tz));
}
+// These tests sometimes run on platforms that have zoneinfo data so old
+// that the transition we are attempting to check does not exist, most
+// notably Android emulators. Fortunately, AndroidZoneInfoSource supports
+// time_zone::version() so, in cases where we've learned that it matters,
+// we can make the check conditionally.
+int VersionCmp(time_zone tz, const std::string& target) {
+ std::string version = tz.version();
+ if (version.empty() && !target.empty()) return 1; // unknown > known
+ return version.compare(target);
+}
+
} // namespace
//
@@ -453,8 +464,8 @@ TEST(Format, ExtendedSecondOffset) {
EXPECT_TRUE(load_time_zone("America/New_York", &tz));
tp = convert(civil_second(1883, 11, 18, 16, 59, 59), utc);
if (tz.lookup(tp).offset == -5 * 60 * 60) {
- // We're likely dealing with zoneinfo that doesn't support really old
- // timestamps, so America/New_York never looks to be on local mean time.
+ // It looks like the tzdata is only 32 bit (probably macOS),
+ // which bottoms out at 1901-12-13T20:45:52+00:00.
} else {
TestFormatSpecifier(tp, tz, "%E*z", "-04:56:02");
TestFormatSpecifier(tp, tz, "%Ez", "-04:56");
@@ -464,12 +475,10 @@ TEST(Format, ExtendedSecondOffset) {
EXPECT_TRUE(load_time_zone("Europe/Moscow", &tz));
tp = convert(civil_second(1919, 6, 30, 23, 59, 59), utc);
-#if defined(__ANDROID__) && __ANDROID_API__ < 25
- // Only Android 'N'.1 and beyond have this tz2016g transition.
-#else
- TestFormatSpecifier(tp, tz, "%E*z", "+04:31:19");
- TestFormatSpecifier(tp, tz, "%Ez", "+04:31");
-#endif
+ if (VersionCmp(tz, "2016g") >= 0) {
+ TestFormatSpecifier(tp, tz, "%E*z", "+04:31:19");
+ TestFormatSpecifier(tp, tz, "%Ez", "+04:31");
+ }
tp += chrono::seconds(1);
TestFormatSpecifier(tp, tz, "%E*z", "+04:00:00");
}