• Home
  • Raw
  • Download

Lines Matching refs:absl

78   constexpr absl::Time t0 = absl::UnixEpoch();  in TEST()
79 static_assert(t0 == absl::Time(), "UnixEpoch"); in TEST()
80 constexpr absl::Time t1 = absl::InfiniteFuture(); in TEST()
81 static_assert(t1 != absl::Time(), "InfiniteFuture"); in TEST()
82 constexpr absl::Time t2 = absl::InfinitePast(); in TEST()
83 static_assert(t2 != absl::Time(), "InfinitePast"); in TEST()
84 constexpr absl::Time t3 = absl::FromUnixNanos(0); in TEST()
85 static_assert(t3 == absl::Time(), "FromUnixNanos"); in TEST()
86 constexpr absl::Time t4 = absl::FromUnixMicros(0); in TEST()
87 static_assert(t4 == absl::Time(), "FromUnixMicros"); in TEST()
88 constexpr absl::Time t5 = absl::FromUnixMillis(0); in TEST()
89 static_assert(t5 == absl::Time(), "FromUnixMillis"); in TEST()
90 constexpr absl::Time t6 = absl::FromUnixSeconds(0); in TEST()
91 static_assert(t6 == absl::Time(), "FromUnixSeconds"); in TEST()
92 constexpr absl::Time t7 = absl::FromTimeT(0); in TEST()
93 static_assert(t7 == absl::Time(), "FromTimeT"); in TEST()
97 absl::Time a; // Default construction in TEST()
98 absl::Time b = a; // Copy construction in TEST()
100 absl::Time c(a); // Copy construction (again) in TEST()
111 const auto ci = absl::UTCTimeZone().At(absl::UnixEpoch()); in TEST()
112 EXPECT_EQ(absl::CivilSecond(1970, 1, 1, 0, 0, 0), ci.cs); in TEST()
113 EXPECT_EQ(absl::ZeroDuration(), ci.subsecond); in TEST()
114 EXPECT_EQ(absl::Weekday::thursday, absl::GetWeekday(ci.cs)); in TEST()
118 absl::TimeZone tz = absl::time_internal::LoadTimeZone("America/New_York"); in TEST()
119 absl::Time t = absl::UnixEpoch(); in TEST()
124 EXPECT_EQ(absl::ZeroDuration(), ci.subsecond); in TEST()
125 EXPECT_EQ(absl::Weekday::wednesday, absl::GetWeekday(ci.cs)); in TEST()
128 t -= absl::Nanoseconds(1); in TEST()
131 EXPECT_EQ(absl::Nanoseconds(999999999), ci.subsecond); in TEST()
132 EXPECT_EQ(absl::Weekday::wednesday, absl::GetWeekday(ci.cs)); in TEST()
135 t += absl::Hours(24) * 2735; in TEST()
136 t += absl::Hours(18) + absl::Minutes(30) + absl::Seconds(15) + in TEST()
137 absl::Nanoseconds(9); in TEST()
140 EXPECT_EQ(8, ci.subsecond / absl::Nanoseconds(1)); in TEST()
141 EXPECT_EQ(absl::Weekday::tuesday, absl::GetWeekday(ci.cs)); in TEST()
145 const absl::Duration d = absl::Nanoseconds(1); in TEST()
146 const absl::Time t0; in TEST()
147 const absl::Time t1 = t0 + d; in TEST()
153 absl::Time t(t0); in TEST()
162 t = absl::UnixEpoch(); in TEST()
163 t += absl::Milliseconds(500); in TEST()
164 EXPECT_EQ(absl::UnixEpoch() + absl::Milliseconds(500), t); in TEST()
165 t += absl::Milliseconds(600); in TEST()
166 EXPECT_EQ(absl::UnixEpoch() + absl::Milliseconds(1100), t); in TEST()
167 t -= absl::Milliseconds(600); in TEST()
168 EXPECT_EQ(absl::UnixEpoch() + absl::Milliseconds(500), t); in TEST()
169 t -= absl::Milliseconds(500); in TEST()
170 EXPECT_EQ(absl::UnixEpoch(), t); in TEST()
174 constexpr absl::Time t1 = absl::FromUnixNanos(0); in TEST()
175 constexpr absl::Time t2 = absl::FromUnixNanos(1); in TEST()
176 constexpr absl::Time t3 = absl::FromUnixNanos(2); in TEST()
178 static_assert(absl::Time() == t1, ""); in TEST()
207 constexpr absl::Time ifuture = absl::InfiniteFuture(); in TEST()
208 constexpr absl::Time ipast = absl::InfinitePast(); in TEST()
216 EXPECT_EQ(ifuture, ifuture + absl::Seconds(1)); in TEST()
217 EXPECT_EQ(ifuture, ifuture - absl::Seconds(1)); in TEST()
218 EXPECT_EQ(ipast, ipast + absl::Seconds(1)); in TEST()
219 EXPECT_EQ(ipast, ipast - absl::Seconds(1)); in TEST()
221 EXPECT_EQ(absl::InfiniteDuration(), ifuture - ifuture); in TEST()
222 EXPECT_EQ(absl::InfiniteDuration(), ifuture - ipast); in TEST()
223 EXPECT_EQ(-absl::InfiniteDuration(), ipast - ifuture); in TEST()
224 EXPECT_EQ(-absl::InfiniteDuration(), ipast - ipast); in TEST()
226 constexpr absl::Time t = absl::UnixEpoch(); // Any finite time. in TEST()
230 EXPECT_EQ(ifuture, t + absl::InfiniteDuration()); in TEST()
231 EXPECT_EQ(ipast, t - absl::InfiniteDuration()); in TEST()
246 TEST_FLOOR_CONVERSION(absl::ToUnixMicros, absl::FromUnixNanos); in TEST()
247 TEST_FLOOR_CONVERSION(absl::ToUnixMillis, absl::FromUnixMicros); in TEST()
248 TEST_FLOOR_CONVERSION(absl::ToUnixSeconds, absl::FromUnixMillis); in TEST()
249 TEST_FLOOR_CONVERSION(absl::ToTimeT, absl::FromUnixMillis); in TEST()
254 EXPECT_EQ(1, absl::ToUnixNanos(absl::UnixEpoch() + absl::Nanoseconds(3) / 2)); in TEST()
255 EXPECT_EQ(1, absl::ToUnixNanos(absl::UnixEpoch() + absl::Nanoseconds(1))); in TEST()
256 EXPECT_EQ(0, absl::ToUnixNanos(absl::UnixEpoch() + absl::Nanoseconds(1) / 2)); in TEST()
257 EXPECT_EQ(0, absl::ToUnixNanos(absl::UnixEpoch() + absl::Nanoseconds(0))); in TEST()
259 absl::ToUnixNanos(absl::UnixEpoch() - absl::Nanoseconds(1) / 2)); in TEST()
260 EXPECT_EQ(-1, absl::ToUnixNanos(absl::UnixEpoch() - absl::Nanoseconds(1))); in TEST()
262 absl::ToUnixNanos(absl::UnixEpoch() - absl::Nanoseconds(3) / 2)); in TEST()
266 absl::ToUniversal(absl::UniversalEpoch() + absl::Nanoseconds(101))); in TEST()
268 absl::ToUniversal(absl::UniversalEpoch() + absl::Nanoseconds(100))); in TEST()
270 absl::ToUniversal(absl::UniversalEpoch() + absl::Nanoseconds(99))); in TEST()
272 absl::ToUniversal(absl::UniversalEpoch() + absl::Nanoseconds(1))); in TEST()
274 absl::ToUniversal(absl::UniversalEpoch() + absl::Nanoseconds(0))); in TEST()
276 absl::ToUniversal(absl::UniversalEpoch() + absl::Nanoseconds(-1))); in TEST()
278 absl::ToUniversal(absl::UniversalEpoch() + absl::Nanoseconds(-99))); in TEST()
280 -1, absl::ToUniversal(absl::UniversalEpoch() + absl::Nanoseconds(-100))); in TEST()
282 -2, absl::ToUniversal(absl::UniversalEpoch() + absl::Nanoseconds(-101))); in TEST()
286 absl::Time t; in TEST()
289 {absl::FromUnixSeconds(1) + absl::Nanoseconds(1), {1, 1}}, in TEST()
290 {absl::FromUnixSeconds(1) + absl::Nanoseconds(1) / 2, {1, 0}}, in TEST()
291 {absl::FromUnixSeconds(1) + absl::Nanoseconds(0), {1, 0}}, in TEST()
292 {absl::FromUnixSeconds(0) + absl::Nanoseconds(0), {0, 0}}, in TEST()
293 {absl::FromUnixSeconds(0) - absl::Nanoseconds(1) / 2, {-1, 999999999}}, in TEST()
294 {absl::FromUnixSeconds(0) - absl::Nanoseconds(1), {-1, 999999999}}, in TEST()
295 {absl::FromUnixSeconds(-1) + absl::Nanoseconds(1), {-1, 1}}, in TEST()
296 {absl::FromUnixSeconds(-1) + absl::Nanoseconds(1) / 2, {-1, 0}}, in TEST()
297 {absl::FromUnixSeconds(-1) + absl::Nanoseconds(0), {-1, 0}}, in TEST()
298 {absl::FromUnixSeconds(-1) - absl::Nanoseconds(1) / 2, {-2, 999999999}}, in TEST()
301 EXPECT_THAT(absl::ToTimespec(test.t), TimespecMatcher(test.ts)); in TEST()
305 absl::Time t; in TEST()
307 {{1, 1}, absl::FromUnixSeconds(1) + absl::Nanoseconds(1)}, in TEST()
308 {{1, 0}, absl::FromUnixSeconds(1) + absl::Nanoseconds(0)}, in TEST()
309 {{0, 0}, absl::FromUnixSeconds(0) + absl::Nanoseconds(0)}, in TEST()
310 {{0, -1}, absl::FromUnixSeconds(0) - absl::Nanoseconds(1)}, in TEST()
311 {{-1, 999999999}, absl::FromUnixSeconds(0) - absl::Nanoseconds(1)}, in TEST()
312 {{-1, 1}, absl::FromUnixSeconds(-1) + absl::Nanoseconds(1)}, in TEST()
313 {{-1, 0}, absl::FromUnixSeconds(-1) + absl::Nanoseconds(0)}, in TEST()
314 {{-1, -1}, absl::FromUnixSeconds(-1) - absl::Nanoseconds(1)}, in TEST()
315 {{-2, 999999999}, absl::FromUnixSeconds(-1) - absl::Nanoseconds(1)}, in TEST()
318 EXPECT_EQ(test.t, absl::TimeFromTimespec(test.ts)); in TEST()
323 absl::Time t; in TEST()
326 {absl::FromUnixSeconds(1) + absl::Microseconds(1), {1, 1}}, in TEST()
327 {absl::FromUnixSeconds(1) + absl::Microseconds(1) / 2, {1, 0}}, in TEST()
328 {absl::FromUnixSeconds(1) + absl::Microseconds(0), {1, 0}}, in TEST()
329 {absl::FromUnixSeconds(0) + absl::Microseconds(0), {0, 0}}, in TEST()
330 {absl::FromUnixSeconds(0) - absl::Microseconds(1) / 2, {-1, 999999}}, in TEST()
331 {absl::FromUnixSeconds(0) - absl::Microseconds(1), {-1, 999999}}, in TEST()
332 {absl::FromUnixSeconds(-1) + absl::Microseconds(1), {-1, 1}}, in TEST()
333 {absl::FromUnixSeconds(-1) + absl::Microseconds(1) / 2, {-1, 0}}, in TEST()
334 {absl::FromUnixSeconds(-1) + absl::Microseconds(0), {-1, 0}}, in TEST()
335 {absl::FromUnixSeconds(-1) - absl::Microseconds(1) / 2, {-2, 999999}}, in TEST()
342 absl::Time t; in TEST()
344 {{1, 1}, absl::FromUnixSeconds(1) + absl::Microseconds(1)}, in TEST()
345 {{1, 0}, absl::FromUnixSeconds(1) + absl::Microseconds(0)}, in TEST()
346 {{0, 0}, absl::FromUnixSeconds(0) + absl::Microseconds(0)}, in TEST()
347 {{0, -1}, absl::FromUnixSeconds(0) - absl::Microseconds(1)}, in TEST()
348 {{-1, 999999}, absl::FromUnixSeconds(0) - absl::Microseconds(1)}, in TEST()
349 {{-1, 1}, absl::FromUnixSeconds(-1) + absl::Microseconds(1)}, in TEST()
350 {{-1, 0}, absl::FromUnixSeconds(-1) + absl::Microseconds(0)}, in TEST()
351 {{-1, -1}, absl::FromUnixSeconds(-1) - absl::Microseconds(1)}, in TEST()
352 {{-2, 999999}, absl::FromUnixSeconds(-1) - absl::Microseconds(1)}, in TEST()
355 EXPECT_EQ(test.t, absl::TimeFromTimeval(test.tv)); in TEST()
360 EXPECT_EQ(min_plus_1, absl::ToUnixSeconds(absl::FromUnixSeconds(min_plus_1))); in TEST()
362 absl::ToUnixSeconds(absl::FromUnixSeconds(min_plus_1) - in TEST()
363 absl::Nanoseconds(1) / 2)); in TEST()
367 absl::ToUnixSeconds( in TEST()
368 absl::FromUnixSeconds(std::numeric_limits<int64_t>::max()) + in TEST()
369 absl::Nanoseconds(1) / 2)); in TEST()
371 absl::ToUnixSeconds( in TEST()
372 absl::FromUnixSeconds(std::numeric_limits<int64_t>::max()))); in TEST()
374 absl::ToUnixSeconds( in TEST()
375 absl::FromUnixSeconds(std::numeric_limits<int64_t>::max()) - in TEST()
376 absl::Nanoseconds(1) / 2)); in TEST()
384 int64_t now_ns = absl::GetCurrentTimeNanos(); in TEST()
385 TEST_CONVERSION_ROUND_TRIP(-1, absl::FromUnixNanos, absl::ToUnixNanos, in TEST()
387 TEST_CONVERSION_ROUND_TRIP(0, absl::FromUnixNanos, absl::ToUnixNanos, in TEST()
389 TEST_CONVERSION_ROUND_TRIP(1, absl::FromUnixNanos, absl::ToUnixNanos, in TEST()
391 TEST_CONVERSION_ROUND_TRIP(now_ns, absl::FromUnixNanos, absl::ToUnixNanos, in TEST()
396 int64_t now_us = absl::GetCurrentTimeNanos() / 1000; in TEST()
397 TEST_CONVERSION_ROUND_TRIP(-1, absl::FromUnixMicros, absl::ToUnixMicros, in TEST()
399 TEST_CONVERSION_ROUND_TRIP(0, absl::FromUnixMicros, absl::ToUnixMicros, in TEST()
401 TEST_CONVERSION_ROUND_TRIP(1, absl::FromUnixMicros, absl::ToUnixMicros, in TEST()
403 TEST_CONVERSION_ROUND_TRIP(now_us, absl::FromUnixMicros, absl::ToUnixMicros, in TEST()
408 int64_t now_ms = absl::GetCurrentTimeNanos() / 1000000; in TEST()
409 TEST_CONVERSION_ROUND_TRIP(-1, absl::FromUnixMillis, absl::ToUnixMillis, in TEST()
411 TEST_CONVERSION_ROUND_TRIP(0, absl::FromUnixMillis, absl::ToUnixMillis, in TEST()
413 TEST_CONVERSION_ROUND_TRIP(1, absl::FromUnixMillis, absl::ToUnixMillis, in TEST()
415 TEST_CONVERSION_ROUND_TRIP(now_ms, absl::FromUnixMillis, absl::ToUnixMillis, in TEST()
421 TEST_CONVERSION_ROUND_TRIP(-1, absl::FromUnixSeconds, absl::ToUnixSeconds, in TEST()
423 TEST_CONVERSION_ROUND_TRIP(0, absl::FromUnixSeconds, absl::ToUnixSeconds, in TEST()
425 TEST_CONVERSION_ROUND_TRIP(1, absl::FromUnixSeconds, absl::ToUnixSeconds, in TEST()
427 TEST_CONVERSION_ROUND_TRIP(now_s, absl::FromUnixSeconds, absl::ToUnixSeconds, in TEST()
433 TEST_CONVERSION_ROUND_TRIP(-1, absl::FromTimeT, absl::ToTimeT, testing::Eq); in TEST()
434 TEST_CONVERSION_ROUND_TRIP(0, absl::FromTimeT, absl::ToTimeT, testing::Eq); in TEST()
435 TEST_CONVERSION_ROUND_TRIP(1, absl::FromTimeT, absl::ToTimeT, testing::Eq); in TEST()
436 TEST_CONVERSION_ROUND_TRIP(now_time_t, absl::FromTimeT, absl::ToTimeT, in TEST()
444 TEST_CONVERSION_ROUND_TRIP(tv, absl::TimeFromTimeval, absl::ToTimeval, in TEST()
448 TEST_CONVERSION_ROUND_TRIP(tv, absl::TimeFromTimeval, absl::ToTimeval, in TEST()
452 TEST_CONVERSION_ROUND_TRIP(tv, absl::TimeFromTimeval, absl::ToTimeval, in TEST()
456 TEST_CONVERSION_ROUND_TRIP(tv, absl::TimeFromTimeval, absl::ToTimeval, in TEST()
460 TEST_CONVERSION_ROUND_TRIP(tv, absl::TimeFromTimeval, absl::ToTimeval, in TEST()
467 TEST_CONVERSION_ROUND_TRIP(ts, absl::TimeFromTimespec, absl::ToTimespec, in TEST()
471 TEST_CONVERSION_ROUND_TRIP(ts, absl::TimeFromTimespec, absl::ToTimespec, in TEST()
475 TEST_CONVERSION_ROUND_TRIP(ts, absl::TimeFromTimespec, absl::ToTimespec, in TEST()
479 TEST_CONVERSION_ROUND_TRIP(ts, absl::TimeFromTimespec, absl::ToTimespec, in TEST()
483 TEST_CONVERSION_ROUND_TRIP(ts, absl::TimeFromTimespec, absl::ToTimespec, in TEST()
487 double now_ud = absl::GetCurrentTimeNanos() / 1000000; in TEST()
488 TEST_CONVERSION_ROUND_TRIP(-1.5, absl::FromUDate, absl::ToUDate, in TEST()
490 TEST_CONVERSION_ROUND_TRIP(-1, absl::FromUDate, absl::ToUDate, in TEST()
492 TEST_CONVERSION_ROUND_TRIP(-0.5, absl::FromUDate, absl::ToUDate, in TEST()
494 TEST_CONVERSION_ROUND_TRIP(0, absl::FromUDate, absl::ToUDate, in TEST()
496 TEST_CONVERSION_ROUND_TRIP(0.5, absl::FromUDate, absl::ToUDate, in TEST()
498 TEST_CONVERSION_ROUND_TRIP(1, absl::FromUDate, absl::ToUDate, in TEST()
500 TEST_CONVERSION_ROUND_TRIP(1.5, absl::FromUDate, absl::ToUDate, in TEST()
502 TEST_CONVERSION_ROUND_TRIP(now_ud, absl::FromUDate, absl::ToUDate, in TEST()
508 (absl::GetCurrentTimeNanos() / 100); in TEST()
509 TEST_CONVERSION_ROUND_TRIP(-1, absl::FromUniversal, absl::ToUniversal, in TEST()
511 TEST_CONVERSION_ROUND_TRIP(0, absl::FromUniversal, absl::ToUniversal, in TEST()
513 TEST_CONVERSION_ROUND_TRIP(1, absl::FromUniversal, absl::ToUniversal, in TEST()
515 TEST_CONVERSION_ROUND_TRIP(now_uni, absl::FromUniversal, absl::ToUniversal, in TEST()
528 EXPECT_EQ(absl::FromTimeT(-1), in TEST()
529 absl::FromChrono(std::chrono::system_clock::from_time_t(-1))); in TEST()
530 EXPECT_EQ(absl::FromTimeT(0), in TEST()
531 absl::FromChrono(std::chrono::system_clock::from_time_t(0))); in TEST()
532 EXPECT_EQ(absl::FromTimeT(1), in TEST()
533 absl::FromChrono(std::chrono::system_clock::from_time_t(1))); in TEST()
536 absl::FromUnixMillis(-1), in TEST()
537 absl::FromChrono(MakeChronoUnixTime(std::chrono::milliseconds(-1)))); in TEST()
538 EXPECT_EQ(absl::FromUnixMillis(0), in TEST()
539 absl::FromChrono(MakeChronoUnixTime(std::chrono::milliseconds(0)))); in TEST()
540 EXPECT_EQ(absl::FromUnixMillis(1), in TEST()
541 absl::FromChrono(MakeChronoUnixTime(std::chrono::milliseconds(1)))); in TEST()
549 EXPECT_EQ(absl::FromUnixSeconds(century_sec), in TEST()
550 absl::FromChrono(chrono_future)); in TEST()
551 EXPECT_EQ(absl::FromUnixSeconds(-century_sec), absl::FromChrono(chrono_past)); in TEST()
555 absl::ToChronoTime(absl::FromUnixSeconds(century_sec))); in TEST()
557 absl::ToChronoTime(absl::FromUnixSeconds(-century_sec))); in TEST()
562 absl::ToChronoTime(absl::FromTimeT(-1))); in TEST()
564 absl::ToChronoTime(absl::FromTimeT(0))); in TEST()
566 absl::ToChronoTime(absl::FromTimeT(1))); in TEST()
569 absl::ToChronoTime(absl::FromUnixMillis(-1))); in TEST()
571 absl::ToChronoTime(absl::FromUnixMillis(0))); in TEST()
573 absl::ToChronoTime(absl::FromUnixMillis(1))); in TEST()
576 const auto tick = absl::Nanoseconds(1) / 4; in TEST()
579 absl::ToChronoTime(absl::UnixEpoch() - tick)); in TEST()
593 std::chrono::duration<absl::int128, std::atto>>; in TEST()
603 EXPECT_EQ(tp, absl::ToChronoTime(absl::FromChrono(tp))); in TEST()
627 const absl::TimeZone nyc = in TEST()
628 absl::time_internal::LoadTimeZone("America/New_York"); in TEST()
632 absl::CivilSecond nov01(2013, 11, 1, 8, 30, 0); in TEST()
634 EXPECT_EQ(absl::TimeZone::TimeInfo::UNIQUE, nov01_ci.kind); in TEST()
636 absl::FormatTime(fmt, nov01_ci.pre, nyc)); in TEST()
639 EXPECT_EQ(nov01_ci.pre, absl::FromCivil(nov01, nyc)); in TEST()
644 absl::CivilSecond mar13(2011, 3, 13, 2, 15, 0); in TEST()
646 EXPECT_EQ(absl::TimeZone::TimeInfo::SKIPPED, mar_ci.kind); in TEST()
648 absl::FormatTime(fmt, mar_ci.pre, nyc)); in TEST()
650 absl::FormatTime(fmt, mar_ci.trans, nyc)); in TEST()
652 absl::FormatTime(fmt, mar_ci.post, nyc)); in TEST()
653 EXPECT_EQ(mar_ci.trans, absl::FromCivil(mar13, nyc)); in TEST()
658 absl::CivilSecond nov06(2011, 11, 6, 1, 15, 0); in TEST()
660 EXPECT_EQ(absl::TimeZone::TimeInfo::REPEATED, nov06_ci.kind); in TEST()
662 absl::FormatTime(fmt, nov06_ci.pre, nyc)); in TEST()
664 absl::FormatTime(fmt, nov06_ci.trans, nyc)); in TEST()
666 absl::FormatTime(fmt, nov06_ci.post, nyc)); in TEST()
667 EXPECT_EQ(nov06_ci.pre, absl::FromCivil(nov06, nyc)); in TEST()
670 absl::CivilSecond minus1(1969, 12, 31, 18, 59, 59); in TEST()
672 EXPECT_EQ(absl::TimeZone::TimeInfo::UNIQUE, minus1_cl.kind); in TEST()
673 EXPECT_EQ(-1, absl::ToTimeT(minus1_cl.pre)); in TEST()
675 absl::FormatTime(fmt, minus1_cl.pre, nyc)); in TEST()
677 absl::FormatTime(fmt, minus1_cl.pre, absl::UTCTimeZone())); in TEST()
683 const absl::TimeZone utc = absl::UTCTimeZone(); in TEST()
687 absl::Time t; in TEST()
690 t = absl::FromCivil( in TEST()
691 absl::CivilSecond(292091940881, kMax, kMax, kMax, kMax, kMax), utc); in TEST()
693 absl::FormatTime(fmt, t, utc)); in TEST()
694 t = absl::FromCivil( in TEST()
695 absl::CivilSecond(292091940882, kMax, kMax, kMax, kMax, kMax), utc); in TEST()
696 EXPECT_EQ("infinite-future", absl::FormatTime(fmt, t, utc)); // no overflow in TEST()
699 t = absl::FromCivil( in TEST()
700 absl::CivilSecond(-292091936940, kMin, kMin, kMin, kMin, kMin), utc); in TEST()
702 absl::FormatTime(fmt, t, utc)); in TEST()
703 t = absl::FromCivil( in TEST()
704 absl::CivilSecond(-292091936941, kMin, kMin, kMin, kMin, kMin), utc); in TEST()
705 EXPECT_EQ("infinite-past", absl::FormatTime(fmt, t, utc)); // no underflow in TEST()
708 t = absl::FromCivil(absl::CivilSecond(1900, 2, 28, 23, 59, 59), utc); in TEST()
710 absl::FormatTime(fmt, t, utc)); in TEST()
711 t = absl::FromCivil(absl::CivilSecond(1900, 3, 1, 0, 0, 0), utc); in TEST()
713 absl::FormatTime(fmt, t, utc)); in TEST()
714 t = absl::FromCivil(absl::CivilSecond(2000, 2, 29, 23, 59, 59), utc); in TEST()
716 absl::FormatTime(fmt, t, utc)); in TEST()
717 t = absl::FromCivil(absl::CivilSecond(2000, 3, 1, 0, 0, 0), utc); in TEST()
719 absl::FormatTime(fmt, t, utc)); in TEST()
723 const absl::TimeZone utc = absl::UTCTimeZone(); in TEST()
727 const absl::Time start = in TEST()
728 absl::FromCivil(absl::CivilSecond(2014, 1, 2, 3, 4, 5), utc); in TEST()
729 const absl::Time end = in TEST()
730 absl::FromCivil(absl::CivilSecond(2014, 1, 5, 3, 4, 5), utc); in TEST()
731 for (absl::Time t = start; t < end; t += absl::Seconds(30)) { in TEST()
733 const time_t tt = absl::ToTimeT(t); in TEST()
754 const absl::TimeZone nyc = in TEST()
755 absl::time_internal::LoadTimeZone("America/New_York"); in TEST()
756 absl::Time t = absl::FromCivil(absl::CivilSecond(2014, 3, 1, 0, 0, 0), nyc); in TEST()
761 t = absl::FromCivil(absl::CivilSecond(2014, 4, 1, 0, 0, 0), nyc); in TEST()
766 tm = ToTM(absl::InfiniteFuture(), nyc); in TEST()
778 tm = ToTM(absl::InfinitePast(), nyc); in TEST()
791 const absl::TimeZone nyc = in TEST()
792 absl::time_internal::LoadTimeZone("America/New_York"); in TEST()
804 absl::Time t = FromTM(tm, nyc); in TEST()
805 EXPECT_EQ("2014-06-28T01:02:03-04:00", absl::FormatTime(t, nyc)); // DST in TEST()
808 EXPECT_EQ("2014-06-28T01:02:03-04:00", absl::FormatTime(t, nyc)); // DST in TEST()
811 EXPECT_EQ("2014-06-28T01:02:03-04:00", absl::FormatTime(t, nyc)); // DST in TEST()
822 EXPECT_EQ("2014-11-02T01:30:42-04:00", absl::FormatTime(t, nyc)); // DST in TEST()
825 EXPECT_EQ("2014-11-02T01:30:42-05:00", absl::FormatTime(t, nyc)); // STD in TEST()
828 EXPECT_EQ("2014-11-02T01:30:42-04:00", absl::FormatTime(t, nyc)); // DST in TEST()
839 EXPECT_EQ("2014-03-09T03:30:42-04:00", absl::FormatTime(t, nyc)); // DST in TEST()
842 EXPECT_EQ("2014-03-09T01:30:42-05:00", absl::FormatTime(t, nyc)); // STD in TEST()
845 EXPECT_EQ("2014-03-09T03:30:42-04:00", absl::FormatTime(t, nyc)); // DST in TEST()
855 t = FromTM(tm, absl::UTCTimeZone()); in TEST()
857 absl::FormatTime(t, absl::UTCTimeZone())); in TEST()
867 t = FromTM(tm, absl::UTCTimeZone()); in TEST()
869 absl::FormatTime(t, absl::UTCTimeZone())); in TEST()
873 const absl::TimeZone nyc = in TEST()
874 absl::time_internal::LoadTimeZone("America/New_York"); in TEST()
877 absl::Time start = absl::FromCivil(absl::CivilHour(2014, 3, 9, 0), nyc); in TEST()
878 absl::Time end = absl::FromCivil(absl::CivilHour(2014, 3, 9, 4), nyc); in TEST()
879 for (absl::Time t = start; t < end; t += absl::Minutes(1)) { in TEST()
881 absl::Time rt = FromTM(tm, nyc); in TEST()
886 start = absl::FromCivil(absl::CivilHour(2014, 11, 2, 0), nyc); in TEST()
887 end = absl::FromCivil(absl::CivilHour(2014, 11, 2, 4), nyc); in TEST()
888 for (absl::Time t = start; t < end; t += absl::Minutes(1)) { in TEST()
890 absl::Time rt = FromTM(tm, nyc); in TEST()
895 start = absl::FromCivil(absl::CivilHour(2014, 6, 27, 22), nyc); in TEST()
896 end = absl::FromCivil(absl::CivilHour(2014, 6, 28, 4), nyc); in TEST()
897 for (absl::Time t = start; t < end; t += absl::Minutes(1)) { in TEST()
899 absl::Time rt = FromTM(tm, nyc); in TEST()
906 const absl::Duration range = absl::Hours(24) * 365.2425 * 100000000000; in TEST()
909 absl::Time bases[2] = {absl::UnixEpoch(), absl::Now()}; in TEST()
911 absl::Time bottom = base - range; in TEST()
912 EXPECT_GT(bottom, bottom - absl::Nanoseconds(1)); in TEST()
913 EXPECT_LT(bottom, bottom + absl::Nanoseconds(1)); in TEST()
914 absl::Time top = base + range; in TEST()
915 EXPECT_GT(top, top - absl::Nanoseconds(1)); in TEST()
916 EXPECT_LT(top, top + absl::Nanoseconds(1)); in TEST()
917 absl::Duration full_range = 2 * range; in TEST()
926 const absl::Time zero; in TEST()
927 const absl::Time max = in TEST()
928 zero + absl::Seconds(std::numeric_limits<int64_t>::max()) + in TEST()
929 absl::Nanoseconds(999999999) + absl::Nanoseconds(3) / 4; in TEST()
930 const absl::Time min = in TEST()
931 zero + absl::Seconds(std::numeric_limits<int64_t>::min()); in TEST()
934 EXPECT_LT(max, absl::InfiniteFuture()); in TEST()
935 EXPECT_GT(min, absl::InfinitePast()); in TEST()
938 EXPECT_GE(absl::UnixEpoch(), min); in TEST()
939 EXPECT_LT(absl::UnixEpoch(), max); in TEST()
942 EXPECT_LT(absl::ZeroDuration(), max - zero); in TEST()
943 EXPECT_LT(absl::ZeroDuration(), in TEST()
944 zero - absl::Nanoseconds(1) / 4 - min); // avoid zero - min in TEST()
947 EXPECT_GT(max, max - absl::Nanoseconds(1) / 4); in TEST()
948 EXPECT_LT(min, min + absl::Nanoseconds(1) / 4); in TEST()
952 const absl::TimeZone utc = absl::UTCTimeZone(); in TEST()
953 absl::Time t; in TEST()
958 t = absl::FromTimeT(tt); in TEST()
959 tt = absl::ToTimeT(t); in TEST()
961 t += absl::Seconds(1); in TEST()
962 tt = absl::ToTimeT(t); in TEST()
964 t += absl::Seconds(1); // no effect in TEST()
965 tt = absl::ToTimeT(t); in TEST()
969 t = absl::FromTimeT(tt); in TEST()
970 tt = absl::ToTimeT(t); in TEST()
972 t -= absl::Seconds(1); in TEST()
973 tt = absl::ToTimeT(t); in TEST()
975 t -= absl::Seconds(1); // no effect in TEST()
976 tt = absl::ToTimeT(t); in TEST()
986 t = absl::TimeFromTimeval(tv); in TEST()
990 t += absl::Microseconds(1); in TEST()
994 t += absl::Microseconds(1); // no effect in TEST()
1001 t = absl::TimeFromTimeval(tv); in TEST()
1005 t -= absl::Microseconds(1); in TEST()
1009 t -= absl::Microseconds(1); // no effect in TEST()
1021 t = absl::TimeFromTimespec(ts); in TEST()
1022 ts = absl::ToTimespec(t); in TEST()
1025 t += absl::Nanoseconds(1); in TEST()
1026 ts = absl::ToTimespec(t); in TEST()
1029 t += absl::Nanoseconds(1); // no effect in TEST()
1030 ts = absl::ToTimespec(t); in TEST()
1036 t = absl::TimeFromTimespec(ts); in TEST()
1037 ts = absl::ToTimespec(t); in TEST()
1040 t -= absl::Nanoseconds(1); in TEST()
1041 ts = absl::ToTimespec(t); in TEST()
1044 t -= absl::Nanoseconds(1); // no effect in TEST()
1045 ts = absl::ToTimespec(t); in TEST()
1050 auto ci = utc.At(absl::InfiniteFuture()); in TEST()
1053 EXPECT_EQ(absl::InfiniteDuration(), ci.subsecond); in TEST()
1054 EXPECT_EQ(absl::Weekday::thursday, absl::GetWeekday(ci.cs)); in TEST()
1055 EXPECT_EQ(365, absl::GetYearDay(ci.cs)); in TEST()
1057 ci = utc.At(absl::InfinitePast()); in TEST()
1060 EXPECT_EQ(-absl::InfiniteDuration(), ci.subsecond); in TEST()
1061 EXPECT_EQ(absl::Weekday::sunday, absl::GetWeekday(ci.cs)); in TEST()
1062 EXPECT_EQ(1, absl::GetYearDay(ci.cs)); in TEST()
1066 t = absl::FromCivil(absl::CivilSecond(292277026596, 12, 4, 15, 30, 6), utc); in TEST()
1068 absl::FormatTime(absl::RFC3339_full, t, utc)); in TEST()
1069 t = absl::FromCivil(absl::CivilSecond(292277026596, 12, 4, 15, 30, 7), utc); in TEST()
1071 absl::FormatTime(absl::RFC3339_full, t, utc)); in TEST()
1073 absl::UnixEpoch() + absl::Seconds(std::numeric_limits<int64_t>::max()), t); in TEST()
1076 const absl::TimeZone plus14 = absl::FixedTimeZone(14 * 60 * 60); in TEST()
1077 t = absl::FromCivil(absl::CivilSecond(292277026596, 12, 5, 5, 30, 7), plus14); in TEST()
1079 absl::FormatTime(absl::RFC3339_full, t, plus14)); in TEST()
1081 absl::UnixEpoch() + absl::Seconds(std::numeric_limits<int64_t>::max()), t); in TEST()
1084 t = absl::FromCivil(absl::CivilSecond(292277026596, 12, 4, 15, 30, 8), utc); in TEST()
1085 EXPECT_EQ("infinite-future", absl::FormatTime(absl::RFC3339_full, t, utc)); in TEST()
1088 t = absl::FromCivil(absl::CivilSecond(-292277022657, 1, 27, 8, 29, 53), utc); in TEST()
1090 absl::FormatTime(absl::RFC3339_full, t, utc)); in TEST()
1091 t = absl::FromCivil(absl::CivilSecond(-292277022657, 1, 27, 8, 29, 52), utc); in TEST()
1093 absl::FormatTime(absl::RFC3339_full, t, utc)); in TEST()
1095 absl::UnixEpoch() + absl::Seconds(std::numeric_limits<int64_t>::min()), t); in TEST()
1098 const absl::TimeZone minus12 = absl::FixedTimeZone(-12 * 60 * 60); in TEST()
1099 t = absl::FromCivil(absl::CivilSecond(-292277022657, 1, 26, 20, 29, 52), in TEST()
1102 absl::FormatTime(absl::RFC3339_full, t, minus12)); in TEST()
1104 absl::UnixEpoch() + absl::Seconds(std::numeric_limits<int64_t>::min()), t); in TEST()
1107 t = absl::FromCivil(absl::CivilSecond(-292277022657, 1, 27, 8, 29, 51), utc); in TEST()
1108 EXPECT_EQ("infinite-past", absl::FormatTime(absl::RFC3339_full, t, utc)); in TEST()
1115 const absl::TimeZone syd = in TEST()
1116 absl::time_internal::LoadTimeZone("Australia/Sydney"); in TEST()
1117 const absl::TimeZone nyc = in TEST()
1118 absl::time_internal::LoadTimeZone("America/New_York"); in TEST()
1119 const absl::Time max = in TEST()
1120 absl::FromUnixSeconds(std::numeric_limits<int64_t>::max()); in TEST()
1121 absl::TimeZone::CivilInfo ci; in TEST()
1122 absl::Time t; in TEST()
1127 t = absl::FromCivil(absl::CivilSecond(292277026596, 12, 5, 2, 30, 7), syd); in TEST()
1131 t = absl::FromCivil(absl::CivilSecond(292277026596, 12, 4, 10, 30, 7), nyc); in TEST()
1135 t = absl::FromCivil(absl::CivilSecond(292277026596, 12, 5, 2, 30, 8), syd); in TEST()
1136 EXPECT_EQ(absl::InfiniteFuture(), t); in TEST()
1137 t = absl::FromCivil(absl::CivilSecond(292277026596, 12, 4, 10, 30, 8), nyc); in TEST()
1138 EXPECT_EQ(absl::InfiniteFuture(), t); in TEST()
1141 t = absl::FromCivil(absl::CivilSecond(292277026596, 12, 5, 2, 30, 9), syd); in TEST()
1142 EXPECT_EQ(absl::InfiniteFuture(), t); in TEST()
1143 t = absl::FromCivil(absl::CivilSecond(292277026596, 12, 4, 10, 30, 9), nyc); in TEST()
1144 EXPECT_EQ(absl::InfiniteFuture(), t); in TEST()
1147 t = absl::FromCivil(absl::CivilSecond::max(), syd); in TEST()
1148 EXPECT_EQ(absl::InfiniteFuture(), t); in TEST()
1149 t = absl::FromCivil(absl::CivilSecond::max(), nyc); in TEST()
1150 EXPECT_EQ(absl::InfiniteFuture(), t); in TEST()
1154 const absl::TimeZone utc = absl::UTCTimeZone(); in TEST()
1155 const absl::CivilSecond cs(2015, 2, 3, 4, 5, 6); in TEST()
1156 absl::Time t = absl::FromCivil(cs, utc); in TEST()
1157 EXPECT_EQ("2015-02-03T04:05:06+00:00", absl::FormatTime(t, utc)); in TEST()
1158 t = absl::FromCivil(absl::CivilMinute(cs), utc); in TEST()
1159 EXPECT_EQ("2015-02-03T04:05:00+00:00", absl::FormatTime(t, utc)); in TEST()
1160 t = absl::FromCivil(absl::CivilHour(cs), utc); in TEST()
1161 EXPECT_EQ("2015-02-03T04:00:00+00:00", absl::FormatTime(t, utc)); in TEST()
1162 t = absl::FromCivil(absl::CivilDay(cs), utc); in TEST()
1163 EXPECT_EQ("2015-02-03T00:00:00+00:00", absl::FormatTime(t, utc)); in TEST()
1164 t = absl::FromCivil(absl::CivilMonth(cs), utc); in TEST()
1165 EXPECT_EQ("2015-02-01T00:00:00+00:00", absl::FormatTime(t, utc)); in TEST()
1166 t = absl::FromCivil(absl::CivilYear(cs), utc); in TEST()
1167 EXPECT_EQ("2015-01-01T00:00:00+00:00", absl::FormatTime(t, utc)); in TEST()
1171 const absl::TimeZone utc = absl::UTCTimeZone(); in TEST()
1175 absl::Time t; in TEST()
1177 t = absl::FromDateTime(std::numeric_limits<absl::civil_year_t>::max(), kMax, in TEST()
1180 absl::FormatTime(ymdhms, t, utc)); // no overflow in TEST()
1181 t = absl::FromDateTime(std::numeric_limits<absl::civil_year_t>::min(), kMin, in TEST()
1183 EXPECT_EQ("infinite-past", absl::FormatTime(ymdhms, t, utc)); // no overflow in TEST()
1186 EXPECT_TRUE(absl::ConvertDateTime(2013, 10, 32, 8, 30, 0, utc).normalized); in TEST()
1187 t = absl::FromDateTime(2015, 1, 1, 0, 0, 60, utc); in TEST()
1188 EXPECT_EQ("2015-01-01 00:01:00", absl::FormatTime(ymdhms, t, utc)); in TEST()
1189 t = absl::FromDateTime(2015, 1, 1, 0, 60, 0, utc); in TEST()
1190 EXPECT_EQ("2015-01-01 01:00:00", absl::FormatTime(ymdhms, t, utc)); in TEST()
1191 t = absl::FromDateTime(2015, 1, 1, 24, 0, 0, utc); in TEST()
1192 EXPECT_EQ("2015-01-02 00:00:00", absl::FormatTime(ymdhms, t, utc)); in TEST()
1193 t = absl::FromDateTime(2015, 1, 32, 0, 0, 0, utc); in TEST()
1194 EXPECT_EQ("2015-02-01 00:00:00", absl::FormatTime(ymdhms, t, utc)); in TEST()
1195 t = absl::FromDateTime(2015, 13, 1, 0, 0, 0, utc); in TEST()
1196 EXPECT_EQ("2016-01-01 00:00:00", absl::FormatTime(ymdhms, t, utc)); in TEST()
1197 t = absl::FromDateTime(2015, 13, 32, 60, 60, 60, utc); in TEST()
1198 EXPECT_EQ("2016-02-03 13:01:00", absl::FormatTime(ymdhms, t, utc)); in TEST()
1199 t = absl::FromDateTime(2015, 1, 1, 0, 0, -1, utc); in TEST()
1200 EXPECT_EQ("2014-12-31 23:59:59", absl::FormatTime(ymdhms, t, utc)); in TEST()
1201 t = absl::FromDateTime(2015, 1, 1, 0, -1, 0, utc); in TEST()
1202 EXPECT_EQ("2014-12-31 23:59:00", absl::FormatTime(ymdhms, t, utc)); in TEST()
1203 t = absl::FromDateTime(2015, 1, 1, -1, 0, 0, utc); in TEST()
1204 EXPECT_EQ("2014-12-31 23:00:00", absl::FormatTime(ymdhms, t, utc)); in TEST()
1205 t = absl::FromDateTime(2015, 1, -1, 0, 0, 0, utc); in TEST()
1206 EXPECT_EQ("2014-12-30 00:00:00", absl::FormatTime(ymdhms, t, utc)); in TEST()
1207 t = absl::FromDateTime(2015, -1, 1, 0, 0, 0, utc); in TEST()
1208 EXPECT_EQ("2014-11-01 00:00:00", absl::FormatTime(ymdhms, t, utc)); in TEST()
1209 t = absl::FromDateTime(2015, -1, -1, -1, -1, -1, utc); in TEST()
1210 EXPECT_EQ("2014-10-29 22:58:59", absl::FormatTime(ymdhms, t, utc)); in TEST()
1214 const auto tz = absl::UTCTimeZone(); in TEST()
1215 absl::TimeZone::CivilTransition trans; in TEST()
1217 auto t = absl::InfinitePast(); in TEST()
1220 t = absl::InfiniteFuture(); in TEST()
1225 const auto tz = absl::UTCTimeZone(); in TEST()
1226 absl::TimeZone::CivilTransition trans; in TEST()
1228 auto t = absl::InfiniteFuture(); in TEST()
1231 t = absl::InfinitePast(); in TEST()
1236 const auto tz = absl::time_internal::LoadTimeZone("America/New_York"); in TEST()
1237 absl::TimeZone::CivilTransition trans; in TEST()
1239 auto t = absl::FromCivil(absl::CivilSecond(2018, 6, 30, 0, 0, 0), tz); in TEST()
1241 EXPECT_EQ(absl::CivilSecond(2018, 11, 4, 2, 0, 0), trans.from); in TEST()
1242 EXPECT_EQ(absl::CivilSecond(2018, 11, 4, 1, 0, 0), trans.to); in TEST()
1244 t = absl::InfiniteFuture(); in TEST()
1247 t = absl::InfinitePast(); in TEST()
1249 if (trans.from == absl::CivilSecond(1918, 03, 31, 2, 0, 0)) { in TEST()
1252 EXPECT_EQ(absl::CivilSecond(1918, 3, 31, 3, 0, 0), trans.to); in TEST()
1254 EXPECT_EQ(absl::CivilSecond(1883, 11, 18, 12, 3, 58), trans.from); in TEST()
1255 EXPECT_EQ(absl::CivilSecond(1883, 11, 18, 12, 0, 0), trans.to); in TEST()
1260 const auto tz = absl::time_internal::LoadTimeZone("America/New_York"); in TEST()
1261 absl::TimeZone::CivilTransition trans; in TEST()
1263 auto t = absl::FromCivil(absl::CivilSecond(2018, 6, 30, 0, 0, 0), tz); in TEST()
1265 EXPECT_EQ(absl::CivilSecond(2018, 3, 11, 2, 0, 0), trans.from); in TEST()
1266 EXPECT_EQ(absl::CivilSecond(2018, 3, 11, 3, 0, 0), trans.to); in TEST()
1268 t = absl::InfinitePast(); in TEST()
1271 t = absl::InfiniteFuture(); in TEST()