summaryrefslogtreecommitdiff
path: root/absl/time/internal/cctz/src
diff options
context:
space:
mode:
Diffstat (limited to 'absl/time/internal/cctz/src')
-rw-r--r--absl/time/internal/cctz/src/time_zone_fixed.cc12
-rw-r--r--absl/time/internal/cctz/src/time_zone_fixed.h6
-rw-r--r--absl/time/internal/cctz/src/time_zone_format.cc12
-rw-r--r--absl/time/internal/cctz/src/time_zone_format_test.cc277
-rw-r--r--absl/time/internal/cctz/src/time_zone_if.h24
-rw-r--r--absl/time/internal/cctz/src/time_zone_impl.cc4
-rw-r--r--absl/time/internal/cctz/src/time_zone_impl.h7
-rw-r--r--absl/time/internal/cctz/src/time_zone_info.cc38
-rw-r--r--absl/time/internal/cctz/src/time_zone_info.h8
-rw-r--r--absl/time/internal/cctz/src/time_zone_libc.cc6
-rw-r--r--absl/time/internal/cctz/src/time_zone_libc.h6
-rw-r--r--absl/time/internal/cctz/src/time_zone_lookup.cc4
-rw-r--r--absl/time/internal/cctz/src/time_zone_lookup_test.cc199
-rw-r--r--absl/time/internal/cctz/src/zone_info_source.cc10
14 files changed, 311 insertions, 302 deletions
diff --git a/absl/time/internal/cctz/src/time_zone_fixed.cc b/absl/time/internal/cctz/src/time_zone_fixed.cc
index 65eba356..598b08fd 100644
--- a/absl/time/internal/cctz/src/time_zone_fixed.cc
+++ b/absl/time/internal/cctz/src/time_zone_fixed.cc
@@ -42,9 +42,9 @@ int Parse02d(const char* p) {
} // namespace
-bool FixedOffsetFromName(const std::string& name, sys_seconds* offset) {
+bool FixedOffsetFromName(const std::string& name, seconds* offset) {
if (name.compare(0, std::string::npos, "UTC", 3) == 0) {
- *offset = sys_seconds::zero();
+ *offset = seconds::zero();
return true;
}
@@ -69,12 +69,12 @@ bool FixedOffsetFromName(const std::string& name, sys_seconds* offset) {
secs += ((hours * 60) + mins) * 60;
if (secs > 24 * 60 * 60) return false; // outside supported offset range
- *offset = sys_seconds(secs * (np[0] == '-' ? -1 : 1)); // "-" means west
+ *offset = seconds(secs * (np[0] == '-' ? -1 : 1)); // "-" means west
return true;
}
-std::string FixedOffsetToName(const sys_seconds& offset) {
- if (offset == sys_seconds::zero()) return "UTC";
+std::string FixedOffsetToName(const seconds& offset) {
+ if (offset == seconds::zero()) return "UTC";
if (offset < std::chrono::hours(-24) || offset > std::chrono::hours(24)) {
// We don't support fixed-offset zones more than 24 hours
// away from UTC to avoid complications in rendering such
@@ -101,7 +101,7 @@ std::string FixedOffsetToName(const sys_seconds& offset) {
return buf;
}
-std::string FixedOffsetToAbbr(const sys_seconds& offset) {
+std::string FixedOffsetToAbbr(const seconds& offset) {
std::string abbr = FixedOffsetToName(offset);
const std::size_t prefix_len = sizeof(kFixedOffsetPrefix) - 1;
if (abbr.size() == prefix_len + 9) { // <prefix>+99:99:99
diff --git a/absl/time/internal/cctz/src/time_zone_fixed.h b/absl/time/internal/cctz/src/time_zone_fixed.h
index 7c9d11db..489b857d 100644
--- a/absl/time/internal/cctz/src/time_zone_fixed.h
+++ b/absl/time/internal/cctz/src/time_zone_fixed.h
@@ -38,9 +38,9 @@ namespace cctz {
// Note: FixedOffsetFromName() fails on syntax errors or when the parsed
// offset exceeds 24 hours. FixedOffsetToName() and FixedOffsetToAbbr()
// both produce "UTC" when the argument offset exceeds 24 hours.
-bool FixedOffsetFromName(const std::string& name, sys_seconds* offset);
-std::string FixedOffsetToName(const sys_seconds& offset);
-std::string FixedOffsetToAbbr(const sys_seconds& offset);
+bool FixedOffsetFromName(const std::string& name, seconds* offset);
+std::string FixedOffsetToName(const seconds& offset);
+std::string FixedOffsetToAbbr(const seconds& offset);
} // namespace cctz
} // namespace time_internal
diff --git a/absl/time/internal/cctz/src/time_zone_format.cc b/absl/time/internal/cctz/src/time_zone_format.cc
index 6d5ccba1..592ab7d3 100644
--- a/absl/time/internal/cctz/src/time_zone_format.cc
+++ b/absl/time/internal/cctz/src/time_zone_format.cc
@@ -277,7 +277,7 @@ const std::int_fast64_t kExp10[kDigits10_64 + 1] = {
// not support the tm_gmtoff and tm_zone extensions to std::tm.
//
// Requires that zero() <= fs < seconds(1).
-std::string format(const std::string& format, const time_point<sys_seconds>& tp,
+std::string format(const std::string& format, const time_point<seconds>& tp,
const detail::femtoseconds& fs, const time_zone& tz) {
std::string result;
result.reserve(format.size()); // A reasonable guess for the result size.
@@ -555,7 +555,7 @@ const char* ParseTM(const char* dp, const char* fmt, std::tm* tm) {
// We also handle the %z specifier to accommodate platforms that do not
// support the tm_gmtoff extension to std::tm. %Z is parsed but ignored.
bool parse(const std::string& format, const std::string& input,
- const time_zone& tz, time_point<sys_seconds>* sec,
+ const time_zone& tz, time_point<seconds>* sec,
detail::femtoseconds* fs, std::string* err) {
// The unparsed input.
const char* data = input.c_str(); // NUL terminated
@@ -822,15 +822,15 @@ bool parse(const std::string& format, const std::string& input,
const auto tp = ptz.lookup(cs).pre;
// Checks for overflow/underflow and returns an error as necessary.
- if (tp == time_point<sys_seconds>::max()) {
- const auto al = ptz.lookup(time_point<sys_seconds>::max());
+ if (tp == time_point<seconds>::max()) {
+ const auto al = ptz.lookup(time_point<seconds>::max());
if (cs > al.cs) {
if (err != nullptr) *err = "Out-of-range field";
return false;
}
}
- if (tp == time_point<sys_seconds>::min()) {
- const auto al = ptz.lookup(time_point<sys_seconds>::min());
+ if (tp == time_point<seconds>::min()) {
+ const auto al = ptz.lookup(time_point<seconds>::min());
if (cs < al.cs) {
if (err != nullptr) *err = "Out-of-range field";
return false;
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 7d5b02ad..33c23984 100644
--- a/absl/time/internal/cctz/src/time_zone_format_test.cc
+++ b/absl/time/internal/cctz/src/time_zone_format_test.cc
@@ -23,15 +23,7 @@
#include "gmock/gmock.h"
#include "gtest/gtest.h"
-using std::chrono::time_point_cast;
-using std::chrono::system_clock;
-using std::chrono::nanoseconds;
-using std::chrono::microseconds;
-using std::chrono::milliseconds;
-using std::chrono::seconds;
-using std::chrono::minutes;
-using std::chrono::hours;
-using testing::HasSubstr;
+namespace chrono = std::chrono;
namespace absl {
namespace time_internal {
@@ -81,33 +73,36 @@ void TestFormatSpecifier(time_point<D> tp, time_zone tz, const std::string& fmt,
TEST(Format, TimePointResolution) {
const char kFmt[] = "%H:%M:%E*S";
const time_zone utc = utc_time_zone();
- const time_point<nanoseconds> t0 = system_clock::from_time_t(1420167845) +
- milliseconds(123) + microseconds(456) +
- nanoseconds(789);
- EXPECT_EQ("03:04:05.123456789",
- format(kFmt, time_point_cast<nanoseconds>(t0), utc));
- EXPECT_EQ("03:04:05.123456",
- format(kFmt, time_point_cast<microseconds>(t0), utc));
- EXPECT_EQ("03:04:05.123",
- format(kFmt, time_point_cast<milliseconds>(t0), utc));
+ const time_point<chrono::nanoseconds> t0 =
+ chrono::system_clock::from_time_t(1420167845) +
+ chrono::milliseconds(123) + chrono::microseconds(456) +
+ chrono::nanoseconds(789);
+ EXPECT_EQ(
+ "03:04:05.123456789",
+ format(kFmt, chrono::time_point_cast<chrono::nanoseconds>(t0), utc));
+ EXPECT_EQ(
+ "03:04:05.123456",
+ format(kFmt, chrono::time_point_cast<chrono::microseconds>(t0), utc));
+ EXPECT_EQ(
+ "03:04:05.123",
+ format(kFmt, chrono::time_point_cast<chrono::milliseconds>(t0), utc));
EXPECT_EQ("03:04:05",
- format(kFmt, time_point_cast<seconds>(t0), utc));
+ format(kFmt, chrono::time_point_cast<chrono::seconds>(t0), utc));
EXPECT_EQ("03:04:05",
- format(kFmt, time_point_cast<sys_seconds>(t0), utc));
+ format(kFmt, chrono::time_point_cast<absl::time_internal::cctz::seconds>(t0), utc));
EXPECT_EQ("03:04:00",
- format(kFmt, time_point_cast<minutes>(t0), utc));
+ format(kFmt, chrono::time_point_cast<chrono::minutes>(t0), utc));
EXPECT_EQ("03:00:00",
- format(kFmt, time_point_cast<hours>(t0), utc));
+ format(kFmt, chrono::time_point_cast<chrono::hours>(t0), utc));
}
TEST(Format, TimePointExtendedResolution) {
const char kFmt[] = "%H:%M:%E*S";
const time_zone utc = utc_time_zone();
- const time_point<sys_seconds> tp =
- std::chrono::time_point_cast<sys_seconds>(
- std::chrono::system_clock::from_time_t(0)) +
- std::chrono::hours(12) + std::chrono::minutes(34) +
- std::chrono::seconds(56);
+ const time_point<absl::time_internal::cctz::seconds> tp =
+ chrono::time_point_cast<absl::time_internal::cctz::seconds>(
+ chrono::system_clock::from_time_t(0)) +
+ chrono::hours(12) + chrono::minutes(34) + chrono::seconds(56);
EXPECT_EQ(
"12:34:56.123456789012345",
@@ -132,7 +127,7 @@ TEST(Format, TimePointExtendedResolution) {
TEST(Format, Basics) {
time_zone tz = utc_time_zone();
- time_point<nanoseconds> tp = system_clock::from_time_t(0);
+ time_point<chrono::nanoseconds> tp = chrono::system_clock::from_time_t(0);
// Starts with a couple basic edge cases.
EXPECT_EQ("", format("", tp, tz));
@@ -145,8 +140,9 @@ TEST(Format, Basics) {
std::string bigger(100000, 'x');
EXPECT_EQ(bigger, format(bigger, tp, tz));
- tp += hours(13) + minutes(4) + seconds(5);
- tp += milliseconds(6) + microseconds(7) + nanoseconds(8);
+ tp += chrono::hours(13) + chrono::minutes(4) + chrono::seconds(5);
+ tp += chrono::milliseconds(6) + chrono::microseconds(7) +
+ chrono::nanoseconds(8);
EXPECT_EQ("1970-01-01", format("%Y-%m-%d", tp, tz));
EXPECT_EQ("13:04:05", format("%H:%M:%S", tp, tz));
EXPECT_EQ("13:04:05.006", format("%H:%M:%E3S", tp, tz));
@@ -156,7 +152,7 @@ TEST(Format, Basics) {
TEST(Format, PosixConversions) {
const time_zone tz = utc_time_zone();
- auto tp = system_clock::from_time_t(0);
+ auto tp = chrono::system_clock::from_time_t(0);
TestFormatSpecifier(tp, tz, "%d", "01");
TestFormatSpecifier(tp, tz, "%e", " 1"); // extension but internal support
@@ -196,7 +192,7 @@ TEST(Format, PosixConversions) {
TEST(Format, LocaleSpecific) {
const time_zone tz = utc_time_zone();
- auto tp = system_clock::from_time_t(0);
+ auto tp = chrono::system_clock::from_time_t(0);
TestFormatSpecifier(tp, tz, "%a", "Thu");
TestFormatSpecifier(tp, tz, "%A", "Thursday");
@@ -205,8 +201,8 @@ TEST(Format, LocaleSpecific) {
// %c should at least produce the numeric year and time-of-day.
const std::string s = format("%c", tp, utc_time_zone());
- EXPECT_THAT(s, HasSubstr("1970"));
- EXPECT_THAT(s, HasSubstr("00:00:00"));
+ EXPECT_THAT(s, testing::HasSubstr("1970"));
+ EXPECT_THAT(s, testing::HasSubstr("00:00:00"));
TestFormatSpecifier(tp, tz, "%p", "AM");
TestFormatSpecifier(tp, tz, "%x", "01/01/70");
@@ -245,7 +241,7 @@ TEST(Format, LocaleSpecific) {
TEST(Format, Escaping) {
const time_zone tz = utc_time_zone();
- auto tp = system_clock::from_time_t(0);
+ auto tp = chrono::system_clock::from_time_t(0);
TestFormatSpecifier(tp, tz, "%%", "%");
TestFormatSpecifier(tp, tz, "%%a", "%a");
@@ -266,8 +262,8 @@ TEST(Format, ExtendedSeconds) {
const time_zone tz = utc_time_zone();
// No subseconds.
- time_point<nanoseconds> tp = system_clock::from_time_t(0);
- tp += seconds(5);
+ time_point<chrono::nanoseconds> tp = chrono::system_clock::from_time_t(0);
+ tp += chrono::seconds(5);
EXPECT_EQ("05", format("%E*S", tp, tz));
EXPECT_EQ("05", format("%E0S", tp, tz));
EXPECT_EQ("05.0", format("%E1S", tp, tz));
@@ -287,7 +283,8 @@ TEST(Format, ExtendedSeconds) {
EXPECT_EQ("05.000000000000000", format("%E15S", tp, tz));
// With subseconds.
- tp += milliseconds(6) + microseconds(7) + nanoseconds(8);
+ tp += chrono::milliseconds(6) + chrono::microseconds(7) +
+ chrono::nanoseconds(8);
EXPECT_EQ("05.006007008", format("%E*S", tp, tz));
EXPECT_EQ("05", format("%E0S", tp, tz));
EXPECT_EQ("05.0", format("%E1S", tp, tz));
@@ -307,17 +304,18 @@ TEST(Format, ExtendedSeconds) {
EXPECT_EQ("05.006007008000000", format("%E15S", tp, tz));
// Times before the Unix epoch.
- tp = system_clock::from_time_t(0) + microseconds(-1);
+ tp = chrono::system_clock::from_time_t(0) + chrono::microseconds(-1);
EXPECT_EQ("1969-12-31 23:59:59.999999",
format("%Y-%m-%d %H:%M:%E*S", tp, tz));
// Here is a "%E*S" case we got wrong for a while. While the first
// instant below is correctly rendered as "...:07.333304", the second
// one used to appear as "...:07.33330499999999999".
- tp = system_clock::from_time_t(0) + microseconds(1395024427333304);
+ tp = chrono::system_clock::from_time_t(0) +
+ chrono::microseconds(1395024427333304);
EXPECT_EQ("2014-03-17 02:47:07.333304",
format("%Y-%m-%d %H:%M:%E*S", tp, tz));
- tp += microseconds(1);
+ tp += chrono::microseconds(1);
EXPECT_EQ("2014-03-17 02:47:07.333305",
format("%Y-%m-%d %H:%M:%E*S", tp, tz));
}
@@ -326,8 +324,8 @@ TEST(Format, ExtendedSubeconds) {
const time_zone tz = utc_time_zone();
// No subseconds.
- time_point<nanoseconds> tp = system_clock::from_time_t(0);
- tp += seconds(5);
+ time_point<chrono::nanoseconds> tp = chrono::system_clock::from_time_t(0);
+ tp += chrono::seconds(5);
EXPECT_EQ("0", format("%E*f", tp, tz));
EXPECT_EQ("", format("%E0f", tp, tz));
EXPECT_EQ("0", format("%E1f", tp, tz));
@@ -347,7 +345,8 @@ TEST(Format, ExtendedSubeconds) {
EXPECT_EQ("000000000000000", format("%E15f", tp, tz));
// With subseconds.
- tp += milliseconds(6) + microseconds(7) + nanoseconds(8);
+ tp += chrono::milliseconds(6) + chrono::microseconds(7) +
+ chrono::nanoseconds(8);
EXPECT_EQ("006007008", format("%E*f", tp, tz));
EXPECT_EQ("", format("%E0f", tp, tz));
EXPECT_EQ("0", format("%E1f", tp, tz));
@@ -367,17 +366,18 @@ TEST(Format, ExtendedSubeconds) {
EXPECT_EQ("006007008000000", format("%E15f", tp, tz));
// Times before the Unix epoch.
- tp = system_clock::from_time_t(0) + microseconds(-1);
+ tp = chrono::system_clock::from_time_t(0) + chrono::microseconds(-1);
EXPECT_EQ("1969-12-31 23:59:59.999999",
format("%Y-%m-%d %H:%M:%S.%E*f", tp, tz));
// Here is a "%E*S" case we got wrong for a while. While the first
// instant below is correctly rendered as "...:07.333304", the second
// one used to appear as "...:07.33330499999999999".
- tp = system_clock::from_time_t(0) + microseconds(1395024427333304);
+ tp = chrono::system_clock::from_time_t(0) +
+ chrono::microseconds(1395024427333304);
EXPECT_EQ("2014-03-17 02:47:07.333304",
format("%Y-%m-%d %H:%M:%S.%E*f", tp, tz));
- tp += microseconds(1);
+ tp += chrono::microseconds(1);
EXPECT_EQ("2014-03-17 02:47:07.333305",
format("%Y-%m-%d %H:%M:%S.%E*f", tp, tz));
}
@@ -392,8 +392,8 @@ TEST(Format, CompareExtendSecondsVsSubseconds) {
auto fmt_B = [](const std::string& prec) { return "%S.%E" + prec + "f"; };
// No subseconds:
- time_point<nanoseconds> tp = system_clock::from_time_t(0);
- tp += seconds(5);
+ time_point<chrono::nanoseconds> tp = chrono::system_clock::from_time_t(0);
+ tp += chrono::seconds(5);
// ... %E*S and %S.%E*f are different.
EXPECT_EQ("05", format(fmt_A("*"), tp, tz));
EXPECT_EQ("05.0", format(fmt_B("*"), tp, tz));
@@ -409,7 +409,8 @@ TEST(Format, CompareExtendSecondsVsSubseconds) {
// With subseconds:
// ... %E*S and %S.%E*f are the same.
- tp += milliseconds(6) + microseconds(7) + nanoseconds(8);
+ tp += chrono::milliseconds(6) + chrono::microseconds(7) +
+ chrono::nanoseconds(8);
EXPECT_EQ("05.006007008", format(fmt_A("*"), tp, tz));
EXPECT_EQ("05.006007008", format(fmt_B("*"), tp, tz));
// ... %E0S and %S.%E0f are different.
@@ -424,7 +425,7 @@ TEST(Format, CompareExtendSecondsVsSubseconds) {
}
TEST(Format, ExtendedOffset) {
- auto tp = system_clock::from_time_t(0);
+ auto tp = chrono::system_clock::from_time_t(0);
time_zone tz = utc_time_zone();
TestFormatSpecifier(tp, tz, "%Ez", "+00:00");
@@ -446,7 +447,7 @@ TEST(Format, ExtendedOffset) {
TEST(Format, ExtendedSecondOffset) {
const time_zone utc = utc_time_zone();
- time_point<seconds> tp;
+ time_point<chrono::seconds> tp;
time_zone tz;
EXPECT_TRUE(load_time_zone("America/New_York", &tz));
@@ -458,7 +459,7 @@ TEST(Format, ExtendedSecondOffset) {
TestFormatSpecifier(tp, tz, "%E*z", "-04:56:02");
TestFormatSpecifier(tp, tz, "%Ez", "-04:56");
}
- tp += seconds(1);
+ tp += chrono::seconds(1);
TestFormatSpecifier(tp, tz, "%E*z", "-05:00:00");
EXPECT_TRUE(load_time_zone("Europe/Moscow", &tz));
@@ -469,7 +470,7 @@ TEST(Format, ExtendedSecondOffset) {
TestFormatSpecifier(tp, tz, "%E*z", "+04:31:19");
TestFormatSpecifier(tp, tz, "%Ez", "+04:31");
#endif
- tp += seconds(1);
+ tp += chrono::seconds(1);
TestFormatSpecifier(tp, tz, "%E*z", "+04:00:00");
}
@@ -510,44 +511,44 @@ TEST(Format, RFC3339Format) {
time_zone tz;
EXPECT_TRUE(load_time_zone("America/Los_Angeles", &tz));
- time_point<nanoseconds> tp =
+ time_point<chrono::nanoseconds> tp =
convert(civil_second(1977, 6, 28, 9, 8, 7), tz);
EXPECT_EQ("1977-06-28T09:08:07-07:00", format(RFC3339_full, tp, tz));
EXPECT_EQ("1977-06-28T09:08:07-07:00", format(RFC3339_sec, tp, tz));
- tp += milliseconds(100);
+ tp += chrono::milliseconds(100);
EXPECT_EQ("1977-06-28T09:08:07.1-07:00", format(RFC3339_full, tp, tz));
EXPECT_EQ("1977-06-28T09:08:07-07:00", format(RFC3339_sec, tp, tz));
- tp += milliseconds(20);
+ tp += chrono::milliseconds(20);
EXPECT_EQ("1977-06-28T09:08:07.12-07:00", format(RFC3339_full, tp, tz));
EXPECT_EQ("1977-06-28T09:08:07-07:00", format(RFC3339_sec, tp, tz));
- tp += milliseconds(3);
+ tp += chrono::milliseconds(3);
EXPECT_EQ("1977-06-28T09:08:07.123-07:00", format(RFC3339_full, tp, tz));
EXPECT_EQ("1977-06-28T09:08:07-07:00", format(RFC3339_sec, tp, tz));
- tp += microseconds(400);
+ tp += chrono::microseconds(400);
EXPECT_EQ("1977-06-28T09:08:07.1234-07:00", format(RFC3339_full, tp, tz));
EXPECT_EQ("1977-06-28T09:08:07-07:00", format(RFC3339_sec, tp, tz));
- tp += microseconds(50);
+ tp += chrono::microseconds(50);
EXPECT_EQ("1977-06-28T09:08:07.12345-07:00", format(RFC3339_full, tp, tz));
EXPECT_EQ("1977-06-28T09:08:07-07:00", format(RFC3339_sec, tp, tz));
- tp += microseconds(6);
+ tp += chrono::microseconds(6);
EXPECT_EQ("1977-06-28T09:08:07.123456-07:00", format(RFC3339_full, tp, tz));
EXPECT_EQ("1977-06-28T09:08:07-07:00", format(RFC3339_sec, tp, tz));
- tp += nanoseconds(700);
+ tp += chrono::nanoseconds(700);
EXPECT_EQ("1977-06-28T09:08:07.1234567-07:00", format(RFC3339_full, tp, tz));
EXPECT_EQ("1977-06-28T09:08:07-07:00", format(RFC3339_sec, tp, tz));
- tp += nanoseconds(80);
+ tp += chrono::nanoseconds(80);
EXPECT_EQ("1977-06-28T09:08:07.12345678-07:00", format(RFC3339_full, tp, tz));
EXPECT_EQ("1977-06-28T09:08:07-07:00", format(RFC3339_sec, tp, tz));
- tp += nanoseconds(9);
+ tp += chrono::nanoseconds(9);
EXPECT_EQ("1977-06-28T09:08:07.123456789-07:00",
format(RFC3339_full, tp, tz));
EXPECT_EQ("1977-06-28T09:08:07-07:00", format(RFC3339_sec, tp, tz));
@@ -570,13 +571,13 @@ TEST(Parse, TimePointResolution) {
const char kFmt[] = "%H:%M:%E*S";
const time_zone utc = utc_time_zone();
- time_point<nanoseconds> tp_ns;
+ time_point<chrono::nanoseconds> tp_ns;
EXPECT_TRUE(parse(kFmt, "03:04:05.123456789", utc, &tp_ns));
EXPECT_EQ("03:04:05.123456789", format(kFmt, tp_ns, utc));
EXPECT_TRUE(parse(kFmt, "03:04:05.123456", utc, &tp_ns));
EXPECT_EQ("03:04:05.123456", format(kFmt, tp_ns, utc));
- time_point<microseconds> tp_us;
+ time_point<chrono::microseconds> tp_us;
EXPECT_TRUE(parse(kFmt, "03:04:05.123456789", utc, &tp_us));
EXPECT_EQ("03:04:05.123456", format(kFmt, tp_us, utc));
EXPECT_TRUE(parse(kFmt, "03:04:05.123456", utc, &tp_us));
@@ -584,7 +585,7 @@ TEST(Parse, TimePointResolution) {
EXPECT_TRUE(parse(kFmt, "03:04:05.123", utc, &tp_us));
EXPECT_EQ("03:04:05.123", format(kFmt, tp_us, utc));
- time_point<milliseconds> tp_ms;
+ time_point<chrono::milliseconds> tp_ms;
EXPECT_TRUE(parse(kFmt, "03:04:05.123456", utc, &tp_ms));
EXPECT_EQ("03:04:05.123", format(kFmt, tp_ms, utc));
EXPECT_TRUE(parse(kFmt, "03:04:05.123", utc, &tp_ms));
@@ -592,17 +593,17 @@ TEST(Parse, TimePointResolution) {
EXPECT_TRUE(parse(kFmt, "03:04:05", utc, &tp_ms));
EXPECT_EQ("03:04:05", format(kFmt, tp_ms, utc));
- time_point<seconds> tp_s;
+ time_point<chrono::seconds> tp_s;
EXPECT_TRUE(parse(kFmt, "03:04:05.123", utc, &tp_s));
EXPECT_EQ("03:04:05", format(kFmt, tp_s, utc));
EXPECT_TRUE(parse(kFmt, "03:04:05", utc, &tp_s));
EXPECT_EQ("03:04:05", format(kFmt, tp_s, utc));
- time_point<minutes> tp_m;
+ time_point<chrono::minutes> tp_m;
EXPECT_TRUE(parse(kFmt, "03:04:05", utc, &tp_m));
EXPECT_EQ("03:04:00", format(kFmt, tp_m, utc));
- time_point<hours> tp_h;
+ time_point<chrono::hours> tp_h;
EXPECT_TRUE(parse(kFmt, "03:04:05", utc, &tp_h));
EXPECT_EQ("03:00:00", format(kFmt, tp_h, utc));
}
@@ -611,7 +612,7 @@ TEST(Parse, TimePointExtendedResolution) {
const char kFmt[] = "%H:%M:%E*S";
const time_zone utc = utc_time_zone();
- time_point<sys_seconds> tp;
+ time_point<absl::time_internal::cctz::seconds> tp;
detail::femtoseconds fs;
EXPECT_TRUE(detail::parse(kFmt, "12:34:56.123456789012345", utc, &tp, &fs));
EXPECT_EQ("12:34:56.123456789012345", detail::format(kFmt, tp, fs, utc));
@@ -629,11 +630,12 @@ TEST(Parse, TimePointExtendedResolution) {
TEST(Parse, Basics) {
time_zone tz = utc_time_zone();
- time_point<nanoseconds> tp = system_clock::from_time_t(1234567890);
+ time_point<chrono::nanoseconds> tp =
+ chrono::system_clock::from_time_t(1234567890);
// Simple edge cases.
EXPECT_TRUE(parse("", "", tz, &tp));
- EXPECT_EQ(system_clock::from_time_t(0), tp); // everything defaulted
+ EXPECT_EQ(chrono::system_clock::from_time_t(0), tp); // everything defaulted
EXPECT_TRUE(parse(" ", " ", tz, &tp));
EXPECT_TRUE(parse(" ", " ", tz, &tp));
EXPECT_TRUE(parse("x", "x", tz, &tp));
@@ -647,7 +649,7 @@ TEST(Parse, Basics) {
TEST(Parse, WithTimeZone) {
time_zone tz;
EXPECT_TRUE(load_time_zone("America/Los_Angeles", &tz));
- time_point<nanoseconds> tp;
+ time_point<chrono::nanoseconds> tp;
// We can parse a std::string without a UTC offset if we supply a timezone.
EXPECT_TRUE(parse("%Y-%m-%d %H:%M:%S", "2013-06-28 19:08:09", tz, &tp));
@@ -672,7 +674,7 @@ TEST(Parse, WithTimeZone) {
TEST(Parse, LeapSecond) {
time_zone tz;
EXPECT_TRUE(load_time_zone("America/Los_Angeles", &tz));
- time_point<nanoseconds> tp;
+ time_point<chrono::nanoseconds> tp;
// ":59" -> ":59"
EXPECT_TRUE(parse(RFC3339_full, "2013-06-28T07:08:59-08:00", tz, &tp));
@@ -696,7 +698,7 @@ TEST(Parse, LeapSecond) {
TEST(Parse, ErrorCases) {
const time_zone tz = utc_time_zone();
- auto tp = system_clock::from_time_t(0);
+ auto tp = chrono::system_clock::from_time_t(0);
// Illegal trailing data.
EXPECT_FALSE(parse("%S", "123", tz, &tp));
@@ -739,7 +741,7 @@ TEST(Parse, ErrorCases) {
TEST(Parse, PosixConversions) {
time_zone tz = utc_time_zone();
- auto tp = system_clock::from_time_t(0);
+ auto tp = chrono::system_clock::from_time_t(0);
const auto reset = convert(civil_second(1977, 6, 28, 9, 8, 7), tz);
tp = reset;
@@ -828,14 +830,14 @@ TEST(Parse, PosixConversions) {
tp = reset;
EXPECT_TRUE(parse("%s", "1234567890", tz, &tp));
- EXPECT_EQ(system_clock::from_time_t(1234567890), tp);
+ EXPECT_EQ(chrono::system_clock::from_time_t(1234567890), tp);
// %s conversion, like %z/%Ez, pays no heed to the optional zone.
time_zone lax;
EXPECT_TRUE(load_time_zone("America/Los_Angeles", &lax));
tp = reset;
EXPECT_TRUE(parse("%s", "1234567890", lax, &tp));
- EXPECT_EQ(system_clock::from_time_t(1234567890), tp);
+ EXPECT_EQ(chrono::system_clock::from_time_t(1234567890), tp);
// This is most important when the time has the same YMDhms
// breakdown in the zone as some other time. For example, ...
@@ -843,16 +845,16 @@ TEST(Parse, PosixConversions) {
// 1414920600 in US/Pacific -> Sun Nov 2 01:30:00 2014 (PST)
tp = reset;
EXPECT_TRUE(parse("%s", "1414917000", lax, &tp));
- EXPECT_EQ(system_clock::from_time_t(1414917000), tp);
+ EXPECT_EQ(chrono::system_clock::from_time_t(1414917000), tp);
tp = reset;
EXPECT_TRUE(parse("%s", "1414920600", lax, &tp));
- EXPECT_EQ(system_clock::from_time_t(1414920600), tp);
+ EXPECT_EQ(chrono::system_clock::from_time_t(1414920600), tp);
#endif
}
TEST(Parse, LocaleSpecific) {
time_zone tz = utc_time_zone();
- auto tp = system_clock::from_time_t(0);
+ auto tp = chrono::system_clock::from_time_t(0);
const auto reset = convert(civil_second(1977, 6, 28, 9, 8, 7), tz);
// %a is parsed but ignored.
@@ -983,7 +985,8 @@ TEST(Parse, LocaleSpecific) {
TEST(Parse, ExtendedSeconds) {
const time_zone tz = utc_time_zone();
- const time_point<nanoseconds> unix_epoch = system_clock::from_time_t(0);
+ const time_point<chrono::nanoseconds> unix_epoch =
+ chrono::system_clock::from_time_t(0);
// All %E<prec>S cases are treated the same as %E*S on input.
auto precisions = {"*", "0", "1", "2", "3", "4", "5", "6", "7",
@@ -991,47 +994,47 @@ TEST(Parse, ExtendedSeconds) {
for (const std::string& prec : precisions) {
const std::string fmt = "%E" + prec + "S";
SCOPED_TRACE(fmt);
- time_point<nanoseconds> tp = unix_epoch;
+ time_point<chrono::nanoseconds> tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "5", tz, &tp));
- EXPECT_EQ(unix_epoch + seconds(5), tp);
+ EXPECT_EQ(unix_epoch + chrono::seconds(5), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "05", tz, &tp));
- EXPECT_EQ(unix_epoch + seconds(5), tp);
+ EXPECT_EQ(unix_epoch + chrono::seconds(5), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "05.0", tz, &tp));
- EXPECT_EQ(unix_epoch + seconds(5), tp);
+ EXPECT_EQ(unix_epoch + chrono::seconds(5), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "05.00", tz, &tp));
- EXPECT_EQ(unix_epoch + seconds(5), tp);
+ EXPECT_EQ(unix_epoch + chrono::seconds(5), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "05.6", tz, &tp));
- EXPECT_EQ(unix_epoch + seconds(5) + milliseconds(600), tp);
+ EXPECT_EQ(unix_epoch + chrono::seconds(5) + chrono::milliseconds(600), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "05.60", tz, &tp));
- EXPECT_EQ(unix_epoch + seconds(5) + milliseconds(600), tp);
+ EXPECT_EQ(unix_epoch + chrono::seconds(5) + chrono::milliseconds(600), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "05.600", tz, &tp));
- EXPECT_EQ(unix_epoch + seconds(5) + milliseconds(600), tp);
+ EXPECT_EQ(unix_epoch + chrono::seconds(5) + chrono::milliseconds(600), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "05.67", tz, &tp));
- EXPECT_EQ(unix_epoch + seconds(5) + milliseconds(670), tp);
+ EXPECT_EQ(unix_epoch + chrono::seconds(5) + chrono::milliseconds(670), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "05.670", tz, &tp));
- EXPECT_EQ(unix_epoch + seconds(5) + milliseconds(670), tp);
+ EXPECT_EQ(unix_epoch + chrono::seconds(5) + chrono::milliseconds(670), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "05.678", tz, &tp));
- EXPECT_EQ(unix_epoch + seconds(5) + milliseconds(678), tp);
+ EXPECT_EQ(unix_epoch + chrono::seconds(5) + chrono::milliseconds(678), tp);
}
// Here is a "%E*S" case we got wrong for a while. The fractional
// part of the first instant is less than 2^31 and was correctly
// parsed, while the second (and any subsecond field >=2^31) failed.
- time_point<nanoseconds> tp = unix_epoch;
+ time_point<chrono::nanoseconds> tp = unix_epoch;
EXPECT_TRUE(parse("%E*S", "0.2147483647", tz, &tp));
- EXPECT_EQ(unix_epoch + nanoseconds(214748364), tp);
+ EXPECT_EQ(unix_epoch + chrono::nanoseconds(214748364), tp);
tp = unix_epoch;
EXPECT_TRUE(parse("%E*S", "0.2147483648", tz, &tp));
- EXPECT_EQ(unix_epoch + nanoseconds(214748364), tp);
+ EXPECT_EQ(unix_epoch + chrono::nanoseconds(214748364), tp);
// We should also be able to specify long strings of digits far
// beyond the current resolution and have them convert the same way.
@@ -1039,18 +1042,18 @@ TEST(Parse, ExtendedSeconds) {
EXPECT_TRUE(parse(
"%E*S", "0.214748364801234567890123456789012345678901234567890123456789",
tz, &tp));
- EXPECT_EQ(unix_epoch + nanoseconds(214748364), tp);
+ EXPECT_EQ(unix_epoch + chrono::nanoseconds(214748364), tp);
}
TEST(Parse, ExtendedSecondsScan) {
const time_zone tz = utc_time_zone();
- time_point<nanoseconds> tp;
+ time_point<chrono::nanoseconds> tp;
for (int ms = 0; ms < 1000; ms += 111) {
for (int us = 0; us < 1000; us += 27) {
const int micros = ms * 1000 + us;
for (int ns = 0; ns < 1000; ns += 9) {
- const auto expected =
- system_clock::from_time_t(0) + nanoseconds(micros * 1000 + ns);
+ const auto expected = chrono::system_clock::from_time_t(0) +
+ chrono::nanoseconds(micros * 1000 + ns);
std::ostringstream oss;
oss << "0." << std::setfill('0') << std::setw(3);
oss << ms << std::setw(3) << us << std::setw(3) << ns;
@@ -1064,7 +1067,8 @@ TEST(Parse, ExtendedSecondsScan) {
TEST(Parse, ExtendedSubeconds) {
const time_zone tz = utc_time_zone();
- const time_point<nanoseconds> unix_epoch = system_clock::from_time_t(0);
+ const time_point<chrono::nanoseconds> unix_epoch =
+ chrono::system_clock::from_time_t(0);
// All %E<prec>f cases are treated the same as %E*f on input.
auto precisions = {"*", "0", "1", "2", "3", "4", "5", "6", "7",
@@ -1072,41 +1076,42 @@ TEST(Parse, ExtendedSubeconds) {
for (const std::string& prec : precisions) {
const std::string fmt = "%E" + prec + "f";
SCOPED_TRACE(fmt);
- time_point<nanoseconds> tp = unix_epoch - seconds(1);
+ time_point<chrono::nanoseconds> tp = unix_epoch - chrono::seconds(1);
EXPECT_TRUE(parse(fmt, "", tz, &tp));
EXPECT_EQ(unix_epoch, tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "6", tz, &tp));
- EXPECT_EQ(unix_epoch + milliseconds(600), tp);
+ EXPECT_EQ(unix_epoch + chrono::milliseconds(600), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "60", tz, &tp));
- EXPECT_EQ(unix_epoch + milliseconds(600), tp);
+ EXPECT_EQ(unix_epoch + chrono::milliseconds(600), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "600", tz, &tp));
- EXPECT_EQ(unix_epoch + milliseconds(600), tp);
+ EXPECT_EQ(unix_epoch + chrono::milliseconds(600), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "67", tz, &tp));
- EXPECT_EQ(unix_epoch + milliseconds(670), tp);
+ EXPECT_EQ(unix_epoch + chrono::milliseconds(670), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "670", tz, &tp));
- EXPECT_EQ(unix_epoch + milliseconds(670), tp);
+ EXPECT_EQ(unix_epoch + chrono::milliseconds(670), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "678", tz, &tp));
- EXPECT_EQ(unix_epoch + milliseconds(678), tp);
+ EXPECT_EQ(unix_epoch + chrono::milliseconds(678), tp);
tp = unix_epoch;
EXPECT_TRUE(parse(fmt, "6789", tz, &tp));
- EXPECT_EQ(unix_epoch + milliseconds(678) + microseconds(900), tp);
+ EXPECT_EQ(
+ unix_epoch + chrono::milliseconds(678) + chrono::microseconds(900), tp);
}
// Here is a "%E*f" case we got wrong for a while. The fractional
// part of the first instant is less than 2^31 and was correctly
// parsed, while the second (and any subsecond field >=2^31) failed.
- time_point<nanoseconds> tp = unix_epoch;
+ time_point<chrono::nanoseconds> tp = unix_epoch;
EXPECT_TRUE(parse("%E*f", "2147483647", tz, &tp));
- EXPECT_EQ(unix_epoch + nanoseconds(214748364), tp);
+ EXPECT_EQ(unix_epoch + chrono::nanoseconds(214748364), tp);
tp = unix_epoch;
EXPECT_TRUE(parse("%E*f", "2147483648", tz, &tp));
- EXPECT_EQ(unix_epoch + nanoseconds(214748364), tp);
+ EXPECT_EQ(unix_epoch + chrono::nanoseconds(214748364), tp);
// We should also be able to specify long strings of digits far
// beyond the current resolution and have them convert the same way.
@@ -1114,11 +1119,11 @@ TEST(Parse, ExtendedSubeconds) {
EXPECT_TRUE(parse(
"%E*f", "214748364801234567890123456789012345678901234567890123456789",
tz, &tp));
- EXPECT_EQ(unix_epoch + nanoseconds(214748364), tp);
+ EXPECT_EQ(unix_epoch + chrono::nanoseconds(214748364), tp);
}
TEST(Parse, ExtendedSubecondsScan) {
- time_point<nanoseconds> tp;
+ time_point<chrono::nanoseconds> tp;
const time_zone tz = utc_time_zone();
for (int ms = 0; ms < 1000; ms += 111) {
for (int us = 0; us < 1000; us += 27) {
@@ -1128,14 +1133,14 @@ TEST(Parse, ExtendedSubecondsScan) {
oss << std::setfill('0') << std::setw(3) << ms;
oss << std::setw(3) << us << std::setw(3) << ns;
const std::string nanos = oss.str();
- const auto expected =
- system_clock::from_time_t(0) + nanoseconds(micros * 1000 + ns);
+ const auto expected = chrono::system_clock::from_time_t(0) +
+ chrono::nanoseconds(micros * 1000 + ns);
for (int ps = 0; ps < 1000; ps += 250) {
std::ostringstream oss;
oss << std::setfill('0') << std::setw(3) << ps;
const std::string input = nanos + oss.str() + "999";
EXPECT_TRUE(parse("%E*f", input, tz, &tp));
- EXPECT_EQ(expected + nanoseconds(ps) / 1000, tp) << input;
+ EXPECT_EQ(expected + chrono::nanoseconds(ps) / 1000, tp) << input;
}
}
}
@@ -1144,7 +1149,7 @@ TEST(Parse, ExtendedSubecondsScan) {
TEST(Parse, ExtendedOffset) {
const time_zone utc = utc_time_zone();
- time_point<sys_seconds> tp;
+ time_point<absl::time_internal::cctz::seconds> tp;
// %z against +-HHMM.
EXPECT_TRUE(parse("%z", "+0000", utc, &tp));
@@ -1194,7 +1199,7 @@ TEST(Parse, ExtendedOffset) {
TEST(Parse, ExtendedSecondOffset) {
const time_zone utc = utc_time_zone();
- time_point<sys_seconds> tp;
+ time_point<absl::time_internal::cctz::seconds> tp;
// %Ez against +-HH:MM:SS.
EXPECT_TRUE(parse("%Ez", "+00:00:00", utc, &tp));
@@ -1263,7 +1268,7 @@ TEST(Parse, ExtendedSecondOffset) {
TEST(Parse, ExtendedYears) {
const time_zone utc = utc_time_zone();
const char e4y_fmt[] = "%E4Y%m%d"; // no separators
- time_point<sys_seconds> tp;
+ time_point<absl::time_internal::cctz::seconds> tp;
// %E4Y consumes exactly four chars, including any sign.
EXPECT_TRUE(parse(e4y_fmt, "-9991127", utc, &tp));
@@ -1294,45 +1299,45 @@ TEST(Parse, ExtendedYears) {
TEST(Parse, RFC3339Format) {
const time_zone tz = utc_time_zone();
- time_point<nanoseconds> tp;
+ time_point<chrono::nanoseconds> tp;
EXPECT_TRUE(parse(RFC3339_sec, "2014-02-12T20:21:00+00:00", tz, &tp));
ExpectTime(tp, tz, 2014, 2, 12, 20, 21, 0, 0, false, "UTC");
// Check that %Ez also accepts "Z" as a synonym for "+00:00".
- time_point<nanoseconds> tp2;
+ time_point<chrono::nanoseconds> tp2;
EXPECT_TRUE(parse(RFC3339_sec, "2014-02-12T20:21:00Z", tz, &tp2));
EXPECT_EQ(tp, tp2);
}
TEST(Parse, MaxRange) {
const time_zone utc = utc_time_zone();
- time_point<sys_seconds> tp;
+ time_point<absl::time_internal::cctz::seconds> tp;
// tests the upper limit using +00:00 offset
EXPECT_TRUE(
parse(RFC3339_sec, "292277026596-12-04T15:30:07+00:00", utc, &tp));
- EXPECT_EQ(tp, time_point<sys_seconds>::max());
+ EXPECT_EQ(tp, time_point<absl::time_internal::cctz::seconds>::max());
EXPECT_FALSE(
parse(RFC3339_sec, "292277026596-12-04T15:30:08+00:00", utc, &tp));
// tests the upper limit using -01:00 offset
EXPECT_TRUE(
parse(RFC3339_sec, "292277026596-12-04T14:30:07-01:00", utc, &tp));
- EXPECT_EQ(tp, time_point<sys_seconds>::max());
+ EXPECT_EQ(tp, time_point<absl::time_internal::cctz::seconds>::max());
EXPECT_FALSE(
parse(RFC3339_sec, "292277026596-12-04T15:30:07-01:00", utc, &tp));
// tests the lower limit using +00:00 offset
EXPECT_TRUE(
parse(RFC3339_sec, "-292277022657-01-27T08:29:52+00:00", utc, &tp));
- EXPECT_EQ(tp, time_point<sys_seconds>::min());
+ EXPECT_EQ(tp, time_point<absl::time_internal::cctz::seconds>::min());
EXPECT_FALSE(
parse(RFC3339_sec, "-292277022657-01-27T08:29:51+00:00", utc, &tp));
// tests the lower limit using +01:00 offset
EXPECT_TRUE(
parse(RFC3339_sec, "-292277022657-01-27T09:29:52+01:00", utc, &tp));
- EXPECT_EQ(tp, time_point<sys_seconds>::min());
+ EXPECT_EQ(tp, time_point<absl::time_internal::cctz::seconds>::min());
EXPECT_FALSE(
parse(RFC3339_sec, "-292277022657-01-27T08:29:51+01:00", utc, &tp));
@@ -1355,11 +1360,11 @@ TEST(FormatParse, RoundTrip) {
time_zone lax;
EXPECT_TRUE(load_time_zone("America/Los_Angeles", &lax));
const auto in = convert(civil_second(1977, 6, 28, 9, 8, 7), lax);
- const auto subseconds = nanoseconds(654321);
+ const auto subseconds = chrono::nanoseconds(654321);
// RFC3339, which renders subseconds.
{
- time_point<nanoseconds> out;
+ time_point<chrono::nanoseconds> out;
const std::string s = format(RFC3339_full, in + subseconds, lax);
EXPECT_TRUE(parse(RFC3339_full, s, lax, &out)) << s;
EXPECT_EQ(in + subseconds, out); // RFC3339_full includes %Ez
@@ -1367,7 +1372,7 @@ TEST(FormatParse, RoundTrip) {
// RFC1123, which only does whole seconds.
{
- time_point<nanoseconds> out;
+ time_point<chrono::nanoseconds> out;
const std::string s = format(RFC1123_full, in, lax);
EXPECT_TRUE(parse(RFC1123_full, s, lax, &out)) << s;
EXPECT_EQ(in, out); // RFC1123_full includes %z
@@ -1380,7 +1385,7 @@ TEST(FormatParse, RoundTrip) {
// Even though we don't know what %c will produce, it should roundtrip,
// but only in the 0-offset timezone.
{
- time_point<nanoseconds> out;
+ time_point<chrono::nanoseconds> out;
time_zone utc = utc_time_zone();
const std::string s = format("%c", in, utc);
EXPECT_TRUE(parse("%c", s, utc, &out)) << s;
@@ -1391,18 +1396,18 @@ TEST(FormatParse, RoundTrip) {
TEST(FormatParse, RoundTripDistantFuture) {
const time_zone utc = utc_time_zone();
- const time_point<sys_seconds> in = time_point<sys_seconds>::max();
+ const time_point<absl::time_internal::cctz::seconds> in = time_point<absl::time_internal::cctz::seconds>::max();
const std::string s = format(RFC3339_full, in, utc);
- time_point<sys_seconds> out;
+ time_point<absl::time_internal::cctz::seconds> out;
EXPECT_TRUE(parse(RFC3339_full, s, utc, &out)) << s;
EXPECT_EQ(in, out);
}
TEST(FormatParse, RoundTripDistantPast) {
const time_zone utc = utc_time_zone();
- const time_point<sys_seconds> in = time_point<sys_seconds>::min();
+ const time_point<absl::time_internal::cctz::seconds> in = time_point<absl::time_internal::cctz::seconds>::min();
const std::string s = format(RFC3339_full, in, utc);
- time_point<sys_seconds> out;
+ time_point<absl::time_internal::cctz::seconds> out;
EXPECT_TRUE(parse(RFC3339_full, s, utc, &out)) << s;
EXPECT_EQ(in, out);
}
diff --git a/absl/time/internal/cctz/src/time_zone_if.h b/absl/time/internal/cctz/src/time_zone_if.h
index ce4da1b7..f10972ae 100644
--- a/absl/time/internal/cctz/src/time_zone_if.h
+++ b/absl/time/internal/cctz/src/time_zone_if.h
@@ -37,30 +37,28 @@ class TimeZoneIf {
virtual ~TimeZoneIf();
virtual time_zone::absolute_lookup BreakTime(
- const time_point<sys_seconds>& tp) const = 0;
+ const time_point<seconds>& tp) const = 0;
virtual time_zone::civil_lookup MakeTime(
const civil_second& cs) const = 0;
virtual std::string Description() const = 0;
- virtual bool NextTransition(time_point<sys_seconds>* tp) const = 0;
- virtual bool PrevTransition(time_point<sys_seconds>* tp) const = 0;
+ virtual bool NextTransition(time_point<seconds>* tp) const = 0;
+ virtual bool PrevTransition(time_point<seconds>* tp) const = 0;
protected:
TimeZoneIf() {}
};
-// Convert between time_point<sys_seconds> and a count of seconds since
-// the Unix epoch. We assume that the std::chrono::system_clock and the
+// Convert between time_point<seconds> and a count of seconds since the
+// Unix epoch. We assume that the std::chrono::system_clock and the
// Unix clock are second aligned, but not that they share an epoch.
-inline std::int_fast64_t ToUnixSeconds(const time_point<sys_seconds>& tp) {
- return (tp - std::chrono::time_point_cast<sys_seconds>(
- std::chrono::system_clock::from_time_t(0)))
- .count();
+inline std::int_fast64_t ToUnixSeconds(const time_point<seconds>& tp) {
+ return (tp - std::chrono::time_point_cast<seconds>(
+ std::chrono::system_clock::from_time_t(0))).count();
}
-inline time_point<sys_seconds> FromUnixSeconds(std::int_fast64_t t) {
- return std::chrono::time_point_cast<sys_seconds>(
- std::chrono::system_clock::from_time_t(0)) +
- sys_seconds(t);
+inline time_point<seconds> FromUnixSeconds(std::int_fast64_t t) {
+ return std::chrono::time_point_cast<seconds>(
+ std::chrono::system_clock::from_time_t(0)) + seconds(t);
}
} // namespace cctz
diff --git a/absl/time/internal/cctz/src/time_zone_impl.cc b/absl/time/internal/cctz/src/time_zone_impl.cc
index b3f635f7..eb96c7ef 100644
--- a/absl/time/internal/cctz/src/time_zone_impl.cc
+++ b/absl/time/internal/cctz/src/time_zone_impl.cc
@@ -45,8 +45,8 @@ bool time_zone::Impl::LoadTimeZone(const std::string& name, time_zone* tz) {
const time_zone::Impl* const utc_impl = UTCImpl();
// First check for UTC (which is never a key in time_zone_map).
- auto offset = sys_seconds::zero();
- if (FixedOffsetFromName(name, &offset) && offset == sys_seconds::zero()) {
+ auto offset = seconds::zero();
+ if (FixedOffsetFromName(name, &offset) && offset == seconds::zero()) {
*tz = time_zone(utc_impl);
return true;
}
diff --git a/absl/time/internal/cctz/src/time_zone_impl.h b/absl/time/internal/cctz/src/time_zone_impl.h
index 2c1c30b6..fef7f226 100644
--- a/absl/time/internal/cctz/src/time_zone_impl.h
+++ b/absl/time/internal/cctz/src/time_zone_impl.h
@@ -48,8 +48,7 @@ class time_zone::Impl {
const std::string& name() const { return name_; }
// Breaks a time_point down to civil-time components in this time zone.
- time_zone::absolute_lookup BreakTime(
- const time_point<sys_seconds>& tp) const {
+ time_zone::absolute_lookup BreakTime(const time_point<seconds>& tp) const {
return zone_->BreakTime(tp);
}
@@ -75,10 +74,10 @@ class time_zone::Impl {
// to NextTransition()/PrevTransition() will eventually return false,
// but it is unspecified exactly when NextTransition(&tp) jumps to false,
// or what time is set by PrevTransition(&tp) for a very distant tp.
- bool NextTransition(time_point<sys_seconds>* tp) const {
+ bool NextTransition(time_point<seconds>* tp) const {
return zone_->NextTransition(tp);
}
- bool PrevTransition(time_point<sys_seconds>* tp) const {
+ bool PrevTransition(time_point<seconds>* tp) const {
return zone_->PrevTransition(tp);
}
diff --git a/absl/time/internal/cctz/src/time_zone_info.cc b/absl/time/internal/cctz/src/time_zone_info.cc
index 20bba28b..cdd11810 100644
--- a/absl/time/internal/cctz/src/time_zone_info.cc
+++ b/absl/time/internal/cctz/src/time_zone_info.cc
@@ -140,7 +140,7 @@ std::int_fast64_t TransOffset(bool leap_year, int jan1_weekday,
return (days * kSecsPerDay) + pt.time.offset;
}
-inline time_zone::civil_lookup MakeUnique(const time_point<sys_seconds>& tp) {
+inline time_zone::civil_lookup MakeUnique(const time_point<seconds>& tp) {
time_zone::civil_lookup cl;
cl.kind = time_zone::civil_lookup::UNIQUE;
cl.pre = cl.trans = cl.post = tp;
@@ -179,7 +179,7 @@ inline civil_second YearShift(const civil_second& cs, year_t shift) {
} // namespace
// What (no leap-seconds) UTC+seconds zoneinfo would look like.
-bool TimeZoneInfo::ResetToBuiltinUTC(const sys_seconds& offset) {
+bool TimeZoneInfo::ResetToBuiltinUTC(const seconds& offset) {
transition_types_.resize(1);
TransitionType& tt(transition_types_.back());
tt.utc_offset = static_cast<std::int_least32_t>(offset.count());
@@ -218,8 +218,8 @@ bool TimeZoneInfo::ResetToBuiltinUTC(const sys_seconds& offset) {
future_spec_.clear(); // never needed for a fixed-offset zone
extended_ = false;
- tt.civil_max = LocalTime(sys_seconds::max().count(), tt).cs;
- tt.civil_min = LocalTime(sys_seconds::min().count(), tt).cs;
+ tt.civil_max = LocalTime(seconds::max().count(), tt).cs;
+ tt.civil_min = LocalTime(seconds::min().count(), tt).cs;
transitions_.shrink_to_fit();
return true;
@@ -565,10 +565,10 @@ bool TimeZoneInfo::Load(const std::string& name, ZoneInfoSource* zip) {
}
// Compute the maximum/minimum civil times that can be converted to a
- // time_point<sys_seconds> for each of the zone's transition types.
+ // time_point<seconds> for each of the zone's transition types.
for (auto& tt : transition_types_) {
- tt.civil_max = LocalTime(sys_seconds::max().count(), tt).cs;
- tt.civil_min = LocalTime(sys_seconds::min().count(), tt).cs;
+ tt.civil_max = LocalTime(seconds::max().count(), tt).cs;
+ tt.civil_min = LocalTime(seconds::min().count(), tt).cs;
}
transitions_.shrink_to_fit();
@@ -713,7 +713,7 @@ bool TimeZoneInfo::Load(const std::string& name) {
// zone never fails because the simple, fixed-offset state can be
// internally generated. Note that this depends on our choice to not
// accept leap-second encoded ("right") zoneinfo.
- auto offset = sys_seconds::zero();
+ auto offset = seconds::zero();
if (FixedOffsetFromName(name, &offset)) {
return ResetToBuiltinUTC(offset);
}
@@ -755,14 +755,14 @@ time_zone::civil_lookup TimeZoneInfo::TimeLocal(const civil_second& cs,
year_t c4_shift) const {
assert(last_year_ - 400 < cs.year() && cs.year() <= last_year_);
time_zone::civil_lookup cl = MakeTime(cs);
- if (c4_shift > sys_seconds::max().count() / kSecsPer400Years) {
- cl.pre = cl.trans = cl.post = time_point<sys_seconds>::max();
+ if (c4_shift > seconds::max().count() / kSecsPer400Years) {
+ cl.pre = cl.trans = cl.post = time_point<seconds>::max();
} else {
- const auto offset = sys_seconds(c4_shift * kSecsPer400Years);
- const auto limit = time_point<sys_seconds>::max() - offset;
+ const auto offset = seconds(c4_shift * kSecsPer400Years);
+ const auto limit = time_point<seconds>::max() - offset;
for (auto* tp : {&cl.pre, &cl.trans, &cl.post}) {
if (*tp > limit) {
- *tp = time_point<sys_seconds>::max();
+ *tp = time_point<seconds>::max();
} else {
*tp += offset;
}
@@ -772,7 +772,7 @@ time_zone::civil_lookup TimeZoneInfo::TimeLocal(const civil_second& cs,
}
time_zone::absolute_lookup TimeZoneInfo::BreakTime(
- const time_point<sys_seconds>& tp) const {
+ const time_point<seconds>& tp) const {
std::int_fast64_t unix_time = ToUnixSeconds(tp);
const std::size_t timecnt = transitions_.size();
assert(timecnt != 0); // We always add a transition.
@@ -788,7 +788,7 @@ time_zone::absolute_lookup TimeZoneInfo::BreakTime(
const std::int_fast64_t diff =
unix_time - transitions_[timecnt - 1].unix_time;
const year_t shift = diff / kSecsPer400Years + 1;
- const auto d = sys_seconds(shift * kSecsPer400Years);
+ const auto d = seconds(shift * kSecsPer400Years);
time_zone::absolute_lookup al = BreakTime(tp - d);
al.cs = YearShift(al.cs, shift * 400);
return al;
@@ -847,7 +847,7 @@ time_zone::civil_lookup TimeZoneInfo::MakeTime(const civil_second& cs) const {
if (tr->prev_civil_sec >= cs) {
// Before first transition, so use the default offset.
const TransitionType& tt(transition_types_[default_transition_type_]);
- if (cs < tt.civil_min) return MakeUnique(time_point<sys_seconds>::min());
+ if (cs < tt.civil_min) return MakeUnique(time_point<seconds>::min());
return MakeUnique(cs - (civil_second() + tt.utc_offset));
}
// tr->prev_civil_sec < cs < tr->civil_sec
@@ -864,7 +864,7 @@ time_zone::civil_lookup TimeZoneInfo::MakeTime(const civil_second& cs) const {
return TimeLocal(YearShift(cs, shift * -400), shift);
}
const TransitionType& tt(transition_types_[tr->type_index]);
- if (cs > tt.civil_max) return MakeUnique(time_point<sys_seconds>::max());
+ if (cs > tt.civil_max) return MakeUnique(time_point<seconds>::max());
return MakeUnique(tr->unix_time + (cs - tr->civil_sec));
}
// tr->civil_sec <= cs <= tr->prev_civil_sec
@@ -895,7 +895,7 @@ std::string TimeZoneInfo::Description() const {
return oss.str();
}
-bool TimeZoneInfo::NextTransition(time_point<sys_seconds>* tp) const {
+bool TimeZoneInfo::NextTransition(time_point<seconds>* tp) const {
if (transitions_.empty()) return false;
const Transition* begin = &transitions_[0];
const Transition* end = begin + transitions_.size();
@@ -919,7 +919,7 @@ bool TimeZoneInfo::NextTransition(time_point<sys_seconds>* tp) const {
return true;
}
-bool TimeZoneInfo::PrevTransition(time_point<sys_seconds>* tp) const {
+bool TimeZoneInfo::PrevTransition(time_point<seconds>* tp) const {
if (transitions_.empty()) return false;
const Transition* begin = &transitions_[0];
const Transition* end = begin + transitions_.size();
diff --git a/absl/time/internal/cctz/src/time_zone_info.h b/absl/time/internal/cctz/src/time_zone_info.h
index b4d1696b..d28443e2 100644
--- a/absl/time/internal/cctz/src/time_zone_info.h
+++ b/absl/time/internal/cctz/src/time_zone_info.h
@@ -71,12 +71,12 @@ class TimeZoneInfo : public TimeZoneIf {
// TimeZoneIf implementations.
time_zone::absolute_lookup BreakTime(
- const time_point<sys_seconds>& tp) const override;
+ const time_point<seconds>& tp) const override;
time_zone::civil_lookup MakeTime(
const civil_second& cs) const override;
std::string Description() const override;
- bool NextTransition(time_point<sys_seconds>* tp) const override;
- bool PrevTransition(time_point<sys_seconds>* tp) const override;
+ bool NextTransition(time_point<seconds>* tp) const override;
+ bool PrevTransition(time_point<seconds>* tp) const override;
private:
struct Header { // counts of:
@@ -98,7 +98,7 @@ class TimeZoneInfo : public TimeZoneIf {
std::uint_fast8_t tt2_index) const;
void ExtendTransitions(const std::string& name, const Header& hdr);
- bool ResetToBuiltinUTC(const sys_seconds& offset);
+ bool ResetToBuiltinUTC(const seconds& offset);
bool Load(const std::string& name, ZoneInfoSource* zip);
// Helpers for BreakTime() and MakeTime().
diff --git a/absl/time/internal/cctz/src/time_zone_libc.cc b/absl/time/internal/cctz/src/time_zone_libc.cc
index b0b56a52..1d727bde 100644
--- a/absl/time/internal/cctz/src/time_zone_libc.cc
+++ b/absl/time/internal/cctz/src/time_zone_libc.cc
@@ -91,7 +91,7 @@ TimeZoneLibC::TimeZoneLibC(const std::string& name)
: local_(name == "localtime") {}
time_zone::absolute_lookup TimeZoneLibC::BreakTime(
- const time_point<sys_seconds>& tp) const {
+ const time_point<seconds>& tp) const {
time_zone::absolute_lookup al;
std::time_t t = ToUnixSeconds(tp);
std::tm tm;
@@ -143,11 +143,11 @@ std::string TimeZoneLibC::Description() const {
return local_ ? "localtime" : "UTC";
}
-bool TimeZoneLibC::NextTransition(time_point<sys_seconds>* tp) const {
+bool TimeZoneLibC::NextTransition(time_point<seconds>* tp) const {
return false;
}
-bool TimeZoneLibC::PrevTransition(time_point<sys_seconds>* tp) const {
+bool TimeZoneLibC::PrevTransition(time_point<seconds>* tp) const {
return false;
}
diff --git a/absl/time/internal/cctz/src/time_zone_libc.h b/absl/time/internal/cctz/src/time_zone_libc.h
index 41f7dde2..4c64cd34 100644
--- a/absl/time/internal/cctz/src/time_zone_libc.h
+++ b/absl/time/internal/cctz/src/time_zone_libc.h
@@ -32,12 +32,12 @@ class TimeZoneLibC : public TimeZoneIf {
// TimeZoneIf implementations.
time_zone::absolute_lookup BreakTime(
- const time_point<sys_seconds>& tp) const override;
+ const time_point<seconds>& tp) const override;
time_zone::civil_lookup MakeTime(
const civil_second& cs) const override;
std::string Description() const override;
- bool NextTransition(time_point<sys_seconds>* tp) const override;
- bool PrevTransition(time_point<sys_seconds>* tp) const override;
+ bool NextTransition(time_point<seconds>* tp) const override;
+ bool PrevTransition(time_point<seconds>* tp) const override;
private:
const bool local_; // localtime or UTC
diff --git a/absl/time/internal/cctz/src/time_zone_lookup.cc b/absl/time/internal/cctz/src/time_zone_lookup.cc
index d549d862..2f6cd98b 100644
--- a/absl/time/internal/cctz/src/time_zone_lookup.cc
+++ b/absl/time/internal/cctz/src/time_zone_lookup.cc
@@ -65,7 +65,7 @@ std::string time_zone::name() const {
}
time_zone::absolute_lookup time_zone::lookup(
- const time_point<sys_seconds>& tp) const {
+ const time_point<seconds>& tp) const {
return time_zone::Impl::get(*this).BreakTime(tp);
}
@@ -85,7 +85,7 @@ time_zone utc_time_zone() {
return time_zone::Impl::UTC(); // avoid name lookup
}
-time_zone fixed_time_zone(const sys_seconds& offset) {
+time_zone fixed_time_zone(const seconds& offset) {
time_zone tz;
load_time_zone(FixedOffsetToName(offset), &tz);
return tz;
diff --git a/absl/time/internal/cctz/src/time_zone_lookup_test.cc b/absl/time/internal/cctz/src/time_zone_lookup_test.cc
index 06b172a8..cd9fc236 100644
--- a/absl/time/internal/cctz/src/time_zone_lookup_test.cc
+++ b/absl/time/internal/cctz/src/time_zone_lookup_test.cc
@@ -24,14 +24,7 @@
#include "absl/time/internal/cctz/include/cctz/civil_time.h"
#include "gtest/gtest.h"
-using std::chrono::time_point_cast;
-using std::chrono::system_clock;
-using std::chrono::nanoseconds;
-using std::chrono::microseconds;
-using std::chrono::milliseconds;
-using std::chrono::seconds;
-using std::chrono::minutes;
-using std::chrono::hours;
+namespace chrono = std::chrono;
namespace absl {
namespace time_internal {
@@ -715,13 +708,13 @@ TEST(TimeZone, NamedTimeZones) {
EXPECT_EQ("America/New_York", nyc.name());
const time_zone syd = LoadZone("Australia/Sydney");
EXPECT_EQ("Australia/Sydney", syd.name());
- const time_zone fixed0 = fixed_time_zone(sys_seconds::zero());
+ const time_zone fixed0 = fixed_time_zone(absl::time_internal::cctz::seconds::zero());
EXPECT_EQ("UTC", fixed0.name());
- const time_zone fixed_pos =
- fixed_time_zone(hours(3) + minutes(25) + seconds(45));
+ const time_zone fixed_pos = fixed_time_zone(
+ chrono::hours(3) + chrono::minutes(25) + chrono::seconds(45));
EXPECT_EQ("Fixed/UTC+03:25:45", fixed_pos.name());
- const time_zone fixed_neg =
- fixed_time_zone(-(hours(12) + minutes(34) + seconds(56)));
+ const time_zone fixed_neg = fixed_time_zone(
+ -(chrono::hours(12) + chrono::minutes(34) + chrono::seconds(56)));
EXPECT_EQ("Fixed/UTC-12:34:56", fixed_neg.name());
}
@@ -731,19 +724,19 @@ TEST(TimeZone, Failures) {
tz = LoadZone("America/Los_Angeles");
EXPECT_FALSE(load_time_zone("Invalid/TimeZone", &tz));
- EXPECT_EQ(system_clock::from_time_t(0),
+ EXPECT_EQ(chrono::system_clock::from_time_t(0),
convert(civil_second(1970, 1, 1, 0, 0, 0), tz)); // UTC
// Ensures that the load still fails on a subsequent attempt.
tz = LoadZone("America/Los_Angeles");
EXPECT_FALSE(load_time_zone("Invalid/TimeZone", &tz));
- EXPECT_EQ(system_clock::from_time_t(0),
+ EXPECT_EQ(chrono::system_clock::from_time_t(0),
convert(civil_second(1970, 1, 1, 0, 0, 0), tz)); // UTC
// Loading an empty std::string timezone should fail.
tz = LoadZone("America/Los_Angeles");
EXPECT_FALSE(load_time_zone("", &tz));
- EXPECT_EQ(system_clock::from_time_t(0),
+ EXPECT_EQ(chrono::system_clock::from_time_t(0),
convert(civil_second(1970, 1, 1, 0, 0, 0), tz)); // UTC
}
@@ -758,7 +751,7 @@ TEST(TimeZone, Equality) {
EXPECT_EQ(implicit_utc, explicit_utc);
EXPECT_EQ(implicit_utc.name(), explicit_utc.name());
- const time_zone fixed_zero = fixed_time_zone(sys_seconds::zero());
+ const time_zone fixed_zero = fixed_time_zone(absl::time_internal::cctz::seconds::zero());
EXPECT_EQ(fixed_zero, LoadZone(fixed_zero.name()));
EXPECT_EQ(fixed_zero, explicit_utc);
@@ -766,23 +759,25 @@ TEST(TimeZone, Equality) {
EXPECT_EQ(fixed_utc, LoadZone(fixed_utc.name()));
EXPECT_EQ(fixed_utc, explicit_utc);
- const time_zone fixed_pos =
- fixed_time_zone(hours(3) + minutes(25) + seconds(45));
+ const time_zone fixed_pos = fixed_time_zone(
+ chrono::hours(3) + chrono::minutes(25) + chrono::seconds(45));
EXPECT_EQ(fixed_pos, LoadZone(fixed_pos.name()));
EXPECT_NE(fixed_pos, explicit_utc);
- const time_zone fixed_neg =
- fixed_time_zone(-(hours(12) + minutes(34) + seconds(56)));
+ const time_zone fixed_neg = fixed_time_zone(
+ -(chrono::hours(12) + chrono::minutes(34) + chrono::seconds(56)));
EXPECT_EQ(fixed_neg, LoadZone(fixed_neg.name()));
EXPECT_NE(fixed_neg, explicit_utc);
- const time_zone fixed_lim = fixed_time_zone(hours(24));
+ const time_zone fixed_lim = fixed_time_zone(chrono::hours(24));
EXPECT_EQ(fixed_lim, LoadZone(fixed_lim.name()));
EXPECT_NE(fixed_lim, explicit_utc);
- const time_zone fixed_ovfl = fixed_time_zone(hours(24) + seconds(1));
+ const time_zone fixed_ovfl =
+ fixed_time_zone(chrono::hours(24) + chrono::seconds(1));
EXPECT_EQ(fixed_ovfl, LoadZone(fixed_ovfl.name()));
EXPECT_EQ(fixed_ovfl, explicit_utc);
- EXPECT_EQ(fixed_time_zone(seconds(1)), fixed_time_zone(seconds(1)));
+ EXPECT_EQ(fixed_time_zone(chrono::seconds(1)),
+ fixed_time_zone(chrono::seconds(1)));
const time_zone local = local_time_zone();
EXPECT_EQ(local, LoadZone(local.name()));
@@ -795,40 +790,43 @@ TEST(TimeZone, Equality) {
TEST(StdChronoTimePoint, TimeTAlignment) {
// Ensures that the Unix epoch and the system clock epoch are an integral
// number of seconds apart. This simplifies conversions to/from time_t.
- auto diff = system_clock::time_point() - system_clock::from_time_t(0);
- EXPECT_EQ(system_clock::time_point::duration::zero(), diff % seconds(1));
+ auto diff = chrono::system_clock::time_point() -
+ chrono::system_clock::from_time_t(0);
+ EXPECT_EQ(chrono::system_clock::time_point::duration::zero(),
+ diff % chrono::seconds(1));
}
TEST(BreakTime, TimePointResolution) {
const time_zone utc = utc_time_zone();
- const auto t0 = system_clock::from_time_t(0);
+ const auto t0 = chrono::system_clock::from_time_t(0);
- ExpectTime(time_point_cast<nanoseconds>(t0), utc,
+ ExpectTime(chrono::time_point_cast<chrono::nanoseconds>(t0), utc,
1970, 1, 1, 0, 0, 0, 0, false, "UTC");
- ExpectTime(time_point_cast<microseconds>(t0), utc,
+ ExpectTime(chrono::time_point_cast<chrono::microseconds>(t0), utc,
1970, 1, 1, 0, 0, 0, 0, false, "UTC");
- ExpectTime(time_point_cast<milliseconds>(t0), utc,
+ ExpectTime(chrono::time_point_cast<chrono::milliseconds>(t0), utc,
1970, 1, 1, 0, 0, 0, 0, false, "UTC");
- ExpectTime(time_point_cast<seconds>(t0), utc,
+ ExpectTime(chrono::time_point_cast<chrono::seconds>(t0), utc,
1970, 1, 1, 0, 0, 0, 0, false, "UTC");
- ExpectTime(time_point_cast<sys_seconds>(t0), utc,
+ ExpectTime(chrono::time_point_cast<absl::time_internal::cctz::seconds>(t0), utc,
1970, 1, 1, 0, 0, 0, 0, false, "UTC");
- ExpectTime(time_point_cast<minutes>(t0), utc,
+ ExpectTime(chrono::time_point_cast<chrono::minutes>(t0), utc,
1970, 1, 1, 0, 0, 0, 0, false, "UTC");
- ExpectTime(time_point_cast<hours>(t0), utc,
+ ExpectTime(chrono::time_point_cast<chrono::hours>(t0), utc,
1970, 1, 1, 0, 0, 0, 0, false, "UTC");
}
TEST(BreakTime, LocalTimeInUTC) {
const time_zone tz = utc_time_zone();
- const auto tp = system_clock::from_time_t(0);
+ const auto tp = chrono::system_clock::from_time_t(0);
ExpectTime(tp, tz, 1970, 1, 1, 0, 0, 0, 0, false, "UTC");
EXPECT_EQ(weekday::thursday, get_weekday(civil_day(convert(tp, tz))));
}
TEST(BreakTime, LocalTimeInUTCUnaligned) {
const time_zone tz = utc_time_zone();
- const auto tp = system_clock::from_time_t(0) - milliseconds(500);
+ const auto tp =
+ chrono::system_clock::from_time_t(0) - chrono::milliseconds(500);
ExpectTime(tp, tz, 1969, 12, 31, 23, 59, 59, 0, false, "UTC");
EXPECT_EQ(weekday::wednesday, get_weekday(civil_day(convert(tp, tz))));
}
@@ -836,15 +834,16 @@ TEST(BreakTime, LocalTimeInUTCUnaligned) {
TEST(BreakTime, LocalTimePosix) {
// See IEEE Std 1003.1-1988 B.2.3 General Terms, Epoch.
const time_zone tz = utc_time_zone();
- const auto tp = system_clock::from_time_t(536457599);
+ const auto tp = chrono::system_clock::from_time_t(536457599);
ExpectTime(tp, tz, 1986, 12, 31, 23, 59, 59, 0, false, "UTC");
EXPECT_EQ(weekday::wednesday, get_weekday(civil_day(convert(tp, tz))));
}
TEST(TimeZoneImpl, LocalTimeInFixed) {
- const sys_seconds offset = -(hours(8) + minutes(33) + seconds(47));
+ const absl::time_internal::cctz::seconds offset =
+ -(chrono::hours(8) + chrono::minutes(33) + chrono::seconds(47));
const time_zone tz = fixed_time_zone(offset);
- const auto tp = system_clock::from_time_t(0);
+ const auto tp = chrono::system_clock::from_time_t(0);
ExpectTime(tp, tz, 1969, 12, 31, 15, 26, 13, offset.count(), false,
"-083347");
EXPECT_EQ(weekday::wednesday, get_weekday(civil_day(convert(tp, tz))));
@@ -852,52 +851,52 @@ TEST(TimeZoneImpl, LocalTimeInFixed) {
TEST(BreakTime, LocalTimeInNewYork) {
const time_zone tz = LoadZone("America/New_York");
- const auto tp = system_clock::from_time_t(45);
+ const auto tp = chrono::system_clock::from_time_t(45);
ExpectTime(tp, tz, 1969, 12, 31, 19, 0, 45, -5 * 60 * 60, false, "EST");
EXPECT_EQ(weekday::wednesday, get_weekday(civil_day(convert(tp, tz))));
}
TEST(BreakTime, LocalTimeInMTV) {
const time_zone tz = LoadZone("America/Los_Angeles");
- const auto tp = system_clock::from_time_t(1380855729);
+ const auto tp = chrono::system_clock::from_time_t(1380855729);
ExpectTime(tp, tz, 2013, 10, 3, 20, 2, 9, -7 * 60 * 60, true, "PDT");
EXPECT_EQ(weekday::thursday, get_weekday(civil_day(convert(tp, tz))));
}
TEST(BreakTime, LocalTimeInSydney) {
const time_zone tz = LoadZone("Australia/Sydney");
- const auto tp = system_clock::from_time_t(90);
+ const auto tp = chrono::system_clock::from_time_t(90);
ExpectTime(tp, tz, 1970, 1, 1, 10, 1, 30, 10 * 60 * 60, false, "AEST");
EXPECT_EQ(weekday::thursday, get_weekday(civil_day(convert(tp, tz))));
}
TEST(MakeTime, TimePointResolution) {
const time_zone utc = utc_time_zone();
- const time_point<nanoseconds> tp_ns =
+ const time_point<chrono::nanoseconds> tp_ns =
convert(civil_second(2015, 1, 2, 3, 4, 5), utc);
EXPECT_EQ("04:05", format("%M:%E*S", tp_ns, utc));
- const time_point<microseconds> tp_us =
+ const time_point<chrono::microseconds> tp_us =
convert(civil_second(2015, 1, 2, 3, 4, 5), utc);
EXPECT_EQ("04:05", format("%M:%E*S", tp_us, utc));
- const time_point<milliseconds> tp_ms =
+ const time_point<chrono::milliseconds> tp_ms =
convert(civil_second(2015, 1, 2, 3, 4, 5), utc);
EXPECT_EQ("04:05", format("%M:%E*S", tp_ms, utc));
- const time_point<seconds> tp_s =
+ const time_point<chrono::seconds> tp_s =
convert(civil_second(2015, 1, 2, 3, 4, 5), utc);
EXPECT_EQ("04:05", format("%M:%E*S", tp_s, utc));
- const time_point<sys_seconds> tp_s64 =
+ const time_point<absl::time_internal::cctz::seconds> tp_s64 =
convert(civil_second(2015, 1, 2, 3, 4, 5), utc);
EXPECT_EQ("04:05", format("%M:%E*S", tp_s64, utc));
- // These next two require time_point_cast because the conversion from a
- // resolution of seconds (the return value of convert()) to a coarser
- // resolution requires an explicit cast.
- const time_point<minutes> tp_m =
- time_point_cast<minutes>(
+ // These next two require chrono::time_point_cast because the conversion
+ // from a resolution of seconds (the return value of convert()) to a
+ // coarser resolution requires an explicit cast.
+ const time_point<chrono::minutes> tp_m =
+ chrono::time_point_cast<chrono::minutes>(
convert(civil_second(2015, 1, 2, 3, 4, 5), utc));
EXPECT_EQ("04:00", format("%M:%E*S", tp_m, utc));
- const time_point<hours> tp_h =
- time_point_cast<hours>(
+ const time_point<chrono::hours> tp_h =
+ chrono::time_point_cast<chrono::hours>(
convert(civil_second(2015, 1, 2, 3, 4, 5), utc));
EXPECT_EQ("00:00", format("%M:%E*S", tp_h, utc));
}
@@ -905,7 +904,7 @@ TEST(MakeTime, TimePointResolution) {
TEST(MakeTime, Normalization) {
const time_zone tz = LoadZone("America/New_York");
const auto tp = convert(civil_second(2009, 2, 13, 18, 31, 30), tz);
- EXPECT_EQ(system_clock::from_time_t(1234567890), tp);
+ EXPECT_EQ(chrono::system_clock::from_time_t(1234567890), tp);
// Now requests for the same time_point but with out-of-range fields.
EXPECT_EQ(tp, convert(civil_second(2008, 14, 13, 18, 31, 30), tz)); // month
@@ -919,67 +918,67 @@ TEST(MakeTime, Normalization) {
TEST(MakeTime, SysSecondsLimits) {
const char RFC3339[] = "%Y-%m-%dT%H:%M:%S%Ez";
const time_zone utc = utc_time_zone();
- const time_zone east = fixed_time_zone(hours(14));
- const time_zone west = fixed_time_zone(-hours(14));
- time_point<sys_seconds> tp;
+ const time_zone east = fixed_time_zone(chrono::hours(14));
+ const time_zone west = fixed_time_zone(-chrono::hours(14));
+ time_point<absl::time_internal::cctz::seconds> tp;
- // Approach the maximal time_point<sys_seconds> value from below.
+ // Approach the maximal time_point<cctz::seconds> value from below.
tp = convert(civil_second(292277026596, 12, 4, 15, 30, 6), utc);
EXPECT_EQ("292277026596-12-04T15:30:06+00:00", format(RFC3339, tp, utc));
tp = convert(civil_second(292277026596, 12, 4, 15, 30, 7), utc);
EXPECT_EQ("292277026596-12-04T15:30:07+00:00", format(RFC3339, tp, utc));
- EXPECT_EQ(time_point<sys_seconds>::max(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::max(), tp);
tp = convert(civil_second(292277026596, 12, 4, 15, 30, 8), utc);
- EXPECT_EQ(time_point<sys_seconds>::max(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::max(), tp);
tp = convert(civil_second::max(), utc);
- EXPECT_EQ(time_point<sys_seconds>::max(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::max(), tp);
// Checks that we can also get the maximal value for a far-east zone.
tp = convert(civil_second(292277026596, 12, 5, 5, 30, 7), east);
EXPECT_EQ("292277026596-12-05T05:30:07+14:00", format(RFC3339, tp, east));
- EXPECT_EQ(time_point<sys_seconds>::max(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::max(), tp);
tp = convert(civil_second(292277026596, 12, 5, 5, 30, 8), east);
- EXPECT_EQ(time_point<sys_seconds>::max(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::max(), tp);
tp = convert(civil_second::max(), east);
- EXPECT_EQ(time_point<sys_seconds>::max(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::max(), tp);
// Checks that we can also get the maximal value for a far-west zone.
tp = convert(civil_second(292277026596, 12, 4, 1, 30, 7), west);
EXPECT_EQ("292277026596-12-04T01:30:07-14:00", format(RFC3339, tp, west));
- EXPECT_EQ(time_point<sys_seconds>::max(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::max(), tp);
tp = convert(civil_second(292277026596, 12, 4, 7, 30, 8), west);
- EXPECT_EQ(time_point<sys_seconds>::max(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::max(), tp);
tp = convert(civil_second::max(), west);
- EXPECT_EQ(time_point<sys_seconds>::max(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::max(), tp);
- // Approach the minimal time_point<sys_seconds> value from above.
+ // Approach the minimal time_point<cctz::seconds> value from above.
tp = convert(civil_second(-292277022657, 1, 27, 8, 29, 53), utc);
EXPECT_EQ("-292277022657-01-27T08:29:53+00:00", format(RFC3339, tp, utc));
tp = convert(civil_second(-292277022657, 1, 27, 8, 29, 52), utc);
EXPECT_EQ("-292277022657-01-27T08:29:52+00:00", format(RFC3339, tp, utc));
- EXPECT_EQ(time_point<sys_seconds>::min(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::min(), tp);
tp = convert(civil_second(-292277022657, 1, 27, 8, 29, 51), utc);
- EXPECT_EQ(time_point<sys_seconds>::min(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::min(), tp);
tp = convert(civil_second::min(), utc);
- EXPECT_EQ(time_point<sys_seconds>::min(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::min(), tp);
// Checks that we can also get the minimal value for a far-east zone.
tp = convert(civil_second(-292277022657, 1, 27, 22, 29, 52), east);
EXPECT_EQ("-292277022657-01-27T22:29:52+14:00", format(RFC3339, tp, east));
- EXPECT_EQ(time_point<sys_seconds>::min(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::min(), tp);
tp = convert(civil_second(-292277022657, 1, 27, 22, 29, 51), east);
- EXPECT_EQ(time_point<sys_seconds>::min(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::min(), tp);
tp = convert(civil_second::min(), east);
- EXPECT_EQ(time_point<sys_seconds>::min(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::min(), tp);
// Checks that we can also get the minimal value for a far-west zone.
tp = convert(civil_second(-292277022657, 1, 26, 18, 29, 52), west);
EXPECT_EQ("-292277022657-01-26T18:29:52-14:00", format(RFC3339, tp, west));
- EXPECT_EQ(time_point<sys_seconds>::min(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::min(), tp);
tp = convert(civil_second(-292277022657, 1, 26, 18, 29, 51), west);
- EXPECT_EQ(time_point<sys_seconds>::min(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::min(), tp);
tp = convert(civil_second::min(), west);
- EXPECT_EQ(time_point<sys_seconds>::min(), tp);
+ EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::min(), tp);
}
TEST(TimeZoneEdgeCase, AmericaNewYork) {
@@ -988,13 +987,13 @@ TEST(TimeZoneEdgeCase, AmericaNewYork) {
// Spring 1:59:59 -> 3:00:00
auto tp = convert(civil_second(2013, 3, 10, 1, 59, 59), tz);
ExpectTime(tp, tz, 2013, 3, 10, 1, 59, 59, -5 * 3600, false, "EST");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 2013, 3, 10, 3, 0, 0, -4 * 3600, true, "EDT");
// Fall 1:59:59 -> 1:00:00
tp = convert(civil_second(2013, 11, 3, 1, 59, 59), tz);
ExpectTime(tp, tz, 2013, 11, 3, 1, 59, 59, -4 * 3600, true, "EDT");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 2013, 11, 3, 1, 0, 0, -5 * 3600, false, "EST");
}
@@ -1004,13 +1003,13 @@ TEST(TimeZoneEdgeCase, AmericaLosAngeles) {
// Spring 1:59:59 -> 3:00:00
auto tp = convert(civil_second(2013, 3, 10, 1, 59, 59), tz);
ExpectTime(tp, tz, 2013, 3, 10, 1, 59, 59, -8 * 3600, false, "PST");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 2013, 3, 10, 3, 0, 0, -7 * 3600, true, "PDT");
// Fall 1:59:59 -> 1:00:00
tp = convert(civil_second(2013, 11, 3, 1, 59, 59), tz);
ExpectTime(tp, tz, 2013, 11, 3, 1, 59, 59, -7 * 3600, true, "PDT");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 2013, 11, 3, 1, 0, 0, -8 * 3600, false, "PST");
}
@@ -1020,13 +1019,13 @@ TEST(TimeZoneEdgeCase, ArizonaNoTransition) {
// No transition in Spring.
auto tp = convert(civil_second(2013, 3, 10, 1, 59, 59), tz);
ExpectTime(tp, tz, 2013, 3, 10, 1, 59, 59, -7 * 3600, false, "MST");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 2013, 3, 10, 2, 0, 0, -7 * 3600, false, "MST");
// No transition in Fall.
tp = convert(civil_second(2013, 11, 3, 1, 59, 59), tz);
ExpectTime(tp, tz, 2013, 11, 3, 1, 59, 59, -7 * 3600, false, "MST");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 2013, 11, 3, 2, 0, 0, -7 * 3600, false, "MST");
}
@@ -1039,7 +1038,7 @@ TEST(TimeZoneEdgeCase, AsiaKathmandu) {
// 504901800 == Wed, 1 Jan 1986 00:15:00 +0545 (+0545)
auto tp = convert(civil_second(1985, 12, 31, 23, 59, 59), tz);
ExpectTime(tp, tz, 1985, 12, 31, 23, 59, 59, 5.5 * 3600, false, "+0530");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 1986, 1, 1, 0, 15, 0, 5.75 * 3600, false, "+0545");
}
@@ -1052,14 +1051,14 @@ TEST(TimeZoneEdgeCase, PacificChatham) {
// 1365256800 == Sun, 7 Apr 2013 02:45:00 +1245 (+1245)
auto tp = convert(civil_second(2013, 4, 7, 3, 44, 59), tz);
ExpectTime(tp, tz, 2013, 4, 7, 3, 44, 59, 13.75 * 3600, true, "+1345");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 2013, 4, 7, 2, 45, 0, 12.75 * 3600, false, "+1245");
// 1380376799 == Sun, 29 Sep 2013 02:44:59 +1245 (+1245)
// 1380376800 == Sun, 29 Sep 2013 03:45:00 +1345 (+1345)
tp = convert(civil_second(2013, 9, 29, 2, 44, 59), tz);
ExpectTime(tp, tz, 2013, 9, 29, 2, 44, 59, 12.75 * 3600, false, "+1245");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 2013, 9, 29, 3, 45, 0, 13.75 * 3600, true, "+1345");
}
@@ -1072,14 +1071,14 @@ TEST(TimeZoneEdgeCase, AustraliaLordHowe) {
// 1365260400 == Sun, 7 Apr 2013 01:30:00 +1030 (+1030)
auto tp = convert(civil_second(2013, 4, 7, 1, 59, 59), tz);
ExpectTime(tp, tz, 2013, 4, 7, 1, 59, 59, 11 * 3600, true, "+11");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 2013, 4, 7, 1, 30, 0, 10.5 * 3600, false, "+1030");
// 1380986999 == Sun, 6 Oct 2013 01:59:59 +1030 (+1030)
// 1380987000 == Sun, 6 Oct 2013 02:30:00 +1100 (+11)
tp = convert(civil_second(2013, 10, 6, 1, 59, 59), tz);
ExpectTime(tp, tz, 2013, 10, 6, 1, 59, 59, 10.5 * 3600, false, "+1030");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 2013, 10, 6, 2, 30, 0, 11 * 3600, true, "+11");
}
@@ -1097,7 +1096,7 @@ TEST(TimeZoneEdgeCase, PacificApia) {
auto tp = convert(civil_second(2011, 12, 29, 23, 59, 59), tz);
ExpectTime(tp, tz, 2011, 12, 29, 23, 59, 59, -10 * 3600, true, "-10");
EXPECT_EQ(363, get_yearday(civil_day(convert(tp, tz))));
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 2011, 12, 31, 0, 0, 0, 14 * 3600, true, "+14");
EXPECT_EQ(365, get_yearday(civil_day(convert(tp, tz))));
}
@@ -1114,7 +1113,7 @@ TEST(TimeZoneEdgeCase, AfricaCairo) {
// 1400191200 == Fri, 16 May 2014 01:00:00 +0300 (EEST)
auto tp = convert(civil_second(2014, 5, 15, 23, 59, 59), tz);
ExpectTime(tp, tz, 2014, 5, 15, 23, 59, 59, 2 * 3600, false, "EET");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 2014, 5, 16, 1, 0, 0, 3 * 3600, true, "EEST");
#endif
}
@@ -1131,7 +1130,7 @@ TEST(TimeZoneEdgeCase, AfricaMonrovia) {
// 63593070 == Fri, 7 Jan 1972 00:44:30 +0000 (GMT)
auto tp = convert(civil_second(1972, 1, 6, 23, 59, 59), tz);
ExpectTime(tp, tz, 1972, 1, 6, 23, 59, 59, -44.5 * 60, false, "MMT");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 1972, 1, 7, 0, 44, 30, 0 * 60, false, "GMT");
#endif
}
@@ -1159,7 +1158,7 @@ TEST(TimeZoneEdgeCase, AmericaJamaica) {
tp = convert(civil_second(1889, 12, 31, 23, 59, 59), tz);
ExpectTime(tp, tz, 1889, 12, 31, 23, 59, 59, -18430, false,
tz.lookup(tp).abbr);
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 1890, 1, 1, 0, 0, 0, -18430, false, "KMT");
#endif
@@ -1168,7 +1167,7 @@ TEST(TimeZoneEdgeCase, AmericaJamaica) {
// 436341600 == Sun, 30 Oct 1983 01:00:00 -0500 (EST)
tp = convert(civil_second(1983, 10, 30, 1, 59, 59), tz);
ExpectTime(tp, tz, 1983, 10, 30, 1, 59, 59, -4 * 3600, true, "EDT");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 1983, 10, 30, 1, 0, 0, -5 * 3600, false, "EST");
// After the last transition.
@@ -1189,7 +1188,7 @@ TEST(TimeZoneEdgeCase, WET) {
// 228877200 == Sun, 3 Apr 1977 02:00:00 +0100 (WEST)
tp = convert(civil_second(1977, 4, 3, 0, 59, 59), tz);
ExpectTime(tp, tz, 1977, 4, 3, 0, 59, 59, 0, false, "WET");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 1977, 4, 3, 2, 0, 0, 1 * 3600, true, "WEST");
// A non-existent time within the first transition.
@@ -1211,12 +1210,12 @@ TEST(TimeZoneEdgeCase, FixedOffsets) {
const time_zone gmtm5 = LoadZone("Etc/GMT+5"); // -0500
auto tp = convert(civil_second(1970, 1, 1, 0, 0, 0), gmtm5);
ExpectTime(tp, gmtm5, 1970, 1, 1, 0, 0, 0, -5 * 3600, false, "-05");
- EXPECT_EQ(system_clock::from_time_t(5 * 3600), tp);
+ EXPECT_EQ(chrono::system_clock::from_time_t(5 * 3600), tp);
const time_zone gmtp5 = LoadZone("Etc/GMT-5"); // +0500
tp = convert(civil_second(1970, 1, 1, 0, 0, 0), gmtp5);
ExpectTime(tp, gmtp5, 1970, 1, 1, 0, 0, 0, 5 * 3600, false, "+05");
- EXPECT_EQ(system_clock::from_time_t(-5 * 3600), tp);
+ EXPECT_EQ(chrono::system_clock::from_time_t(-5 * 3600), tp);
}
TEST(TimeZoneEdgeCase, NegativeYear) {
@@ -1225,7 +1224,7 @@ TEST(TimeZoneEdgeCase, NegativeYear) {
auto tp = convert(civil_second(0, 1, 1, 0, 0, 0), tz);
ExpectTime(tp, tz, 0, 1, 1, 0, 0, 0, 0 * 3600, false, "UTC");
EXPECT_EQ(weekday::saturday, get_weekday(civil_day(convert(tp, tz))));
- tp -= seconds(1);
+ tp -= absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, -1, 12, 31, 23, 59, 59, 0 * 3600, false, "UTC");
EXPECT_EQ(weekday::friday, get_weekday(civil_day(convert(tp, tz))));
}
@@ -1239,7 +1238,7 @@ TEST(TimeZoneEdgeCase, UTC32bitLimit) {
// 2147483648 == Tue, 19 Jan 2038 03:14:08 +0000 (UTC)
auto tp = convert(civil_second(2038, 1, 19, 3, 14, 7), tz);
ExpectTime(tp, tz, 2038, 1, 19, 3, 14, 7, 0 * 3600, false, "UTC");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 2038, 1, 19, 3, 14, 8, 0 * 3600, false, "UTC");
}
@@ -1252,7 +1251,7 @@ TEST(TimeZoneEdgeCase, UTC5DigitYear) {
// 253402300800 == Sat, 1 Jan 1000 00:00:00 +0000 (UTC)
auto tp = convert(civil_second(9999, 12, 31, 23, 59, 59), tz);
ExpectTime(tp, tz, 9999, 12, 31, 23, 59, 59, 0 * 3600, false, "UTC");
- tp += seconds(1);
+ tp += absl::time_internal::cctz::seconds(1);
ExpectTime(tp, tz, 10000, 1, 1, 0, 0, 0, 0 * 3600, false, "UTC");
}
diff --git a/absl/time/internal/cctz/src/zone_info_source.cc b/absl/time/internal/cctz/src/zone_info_source.cc
index b77c0a58..ee7500b6 100644
--- a/absl/time/internal/cctz/src/zone_info_source.cc
+++ b/absl/time/internal/cctz/src/zone_info_source.cc
@@ -60,9 +60,17 @@ ZoneInfoSourceFactory default_factory = DefaultFactory;
#else
#error Unsupported MSVC platform
#endif
-#else
+#else // _MSC_VER
+#if !defined(__has_attribute)
+#define __has_attribute(x) 0
+#endif
+#if __has_attribute(weak) || defined(__GNUC__)
ZoneInfoSourceFactory zone_info_source_factory
__attribute__((weak)) = DefaultFactory;
+#else
+// Make it a "strong" definition if we have no other choice.
+ZoneInfoSourceFactory zone_info_source_factory = DefaultFactory;
+#endif
#endif // _MSC_VER
} // namespace cctz_extension