about summary refs log tree commit diff
path: root/absl/time
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2019-07-02T19·50-0700
committerMark Barolak <mbar@google.com>2019-07-02T21·23-0400
commite6b050212c859fbaf67abac76105da10ec348274 (patch)
tree820bfd57d6117171e84089e6ff23d6333bb79c43 /absl/time
parentc964fcffac27bd4a9ff67fe393410dd1146ef8b8 (diff)
Export of internal Abseil changes.
--
c2e2e2b21c3fe59b63279e7418c93c7289ee3e27 by Mark Barolak <mbar@google.com>:

Import of CCTZ from GitHub.

PiperOrigin-RevId: 256220326

--
3996b01f0c3eb60f72825b154dce8019b6215f1d by Derek Mauro <dmauro@google.com>:

Add GCC 4.9 test script. This will become our new minumum version and
GCC 4.8 will be removed soon.

PiperOrigin-RevId: 256160891

--
2c13aa44bc8e497ebae9abe8b8adf73c2152622d by Abseil Team <absl-team@google.com>:

[Trivial] tweak flat_hash_map.h doc comment

The comment is probably right both ways, but the lack of an "if" here seemed jarring to me.

PiperOrigin-RevId: 256089069

--
16bc03b9b30fbf08d7dc61025fa8ec4b57077be8 by Abseil Team <absl-team@google.com>:

Fix symbolization for elf files whose SYMTAB section is stripped, but have a DYNSYM section.

Previously, if we did not find a SYMTAB section, we would bail out of symbolization early, rather than checking the DYNSYM section.

PiperOrigin-RevId: 256061954

--
4c60ee329b1eeb0b0d10c4f76f282e5fbae2c5b2 by Derek Mauro <dmauro@google.com>:

Update to LLVM r363242 and Bazel 0.27.0

PiperOrigin-RevId: 256024405

--
18e1ba970d33f122026803d8ca90035b9088949d by Eric Fiselier <ericwf@google.com>:

Disable variant tests that break with P0608R3

PiperOrigin-RevId: 255975764

--
0a89858464977e86096b62476faa3b64eb94aa1d by Abseil Team <absl-team@google.com>:

Internal change

PiperOrigin-RevId: 255891019

--
9b7424cac66f5407f0ed74ed288bf3099a4fa330 by CJ Johnson <johnsoncj@google.com>:

Updates the implementation of InlinedVector::insert(...) to be exception safe and adds an exception safety tests for insert(...)

PiperOrigin-RevId: 255881809

--
1288f4ba3883c510d92b09437fb8b051c19aa241 by CJ Johnson <johnsoncj@google.com>:

Updates the implementation of InlinedVector::insert(...) to be exception safe and adds an exception safety tests for insert(...)

PiperOrigin-RevId: 255875277

--
39c04f3621491eaff9e2eda619718d5b5f20fbd9 by Abseil Team <absl-team@google.com>:

Use a typedef to allow building with NVCC

Without this change NVCC fails to compile compressed_tuple.h.  NVCC is relevant
because TensorFlow uses NVCC on Ubuntu and inclues abseil.

PiperOrigin-RevId: 255850176

--
e23f0309ccad69eb508ca02c9034cd4cdd740da0 by Abseil Team <absl-team@google.com>:

Internal change

PiperOrigin-RevId: 255787167

--
054aafcebf595077054164f1da3703124ab209b4 by Abseil Team <absl-team@google.com>:

Updates the ScopedAllocatorWorks test for InlinedVector to not rely on the byte count allocated by the standard library

In doing so, removes LegacyNextCapacityFrom(...) impl function from InlinedVector

Also applies clang-format to the test file

PiperOrigin-RevId: 255760356

--
eb05fc9f78e3a163c93f1866e9fe9a8ad0d01622 by Abseil Team <absl-team@google.com>:

Internal change

PiperOrigin-RevId: 255706834

--
97abb824417604c45d9fcbb3e4ff1aa3000836f2 by Jorg Brown <jorg@google.com>:

Enhance compatibility of abseil's strings package with nvcc.

PiperOrigin-RevId: 255688500

--
efc5b9c221ee31e15d10b35d31c8f3ae6eddaa8c by Abseil Team <absl-team@google.com>:

Follow CCTZ's lead and allow GetWeekday() and GetYearDay() to be
called with any civil-time type.  A CivilSecond, for example, has
a weekday just as much as a CivilDay does.

PiperOrigin-RevId: 255659840

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

Increase the timeout of randen_engine_test.
It seems to timeout under TSAN often enough to justify the increase.

PiperOrigin-RevId: 255628086

--
160976ba47c7c6eb57af08e21f8eb640aa51e91b by Derek Mauro <dmauro@google.com>:

Update CMake documentation
Fixes https://github.com/abseil/abseil-cpp/issues/332

PiperOrigin-RevId: 255607313
GitOrigin-RevId: c2e2e2b21c3fe59b63279e7418c93c7289ee3e27
Change-Id: Iba4ac7ed23cbcdb22965b4958601f689be92cda4
Diffstat (limited to 'absl/time')
-rw-r--r--absl/time/civil_time.h12
-rw-r--r--absl/time/civil_time_test.cc12
-rw-r--r--absl/time/internal/cctz/include/cctz/civil_time_detail.h14
-rw-r--r--absl/time/internal/cctz/src/time_zone_info.cc4
-rw-r--r--absl/time/time.cc5
-rw-r--r--absl/time/time_test.cc16
6 files changed, 36 insertions, 27 deletions
diff --git a/absl/time/civil_time.h b/absl/time/civil_time.h
index 6bb7eec74157..beaf7d898551 100644
--- a/absl/time/civil_time.h
+++ b/absl/time/civil_time.h
@@ -370,15 +370,15 @@ using Weekday = time_internal::cctz::weekday;
 
 // GetWeekday()
 //
-// Returns the absl::Weekday for the given absl::CivilDay.
+// Returns the absl::Weekday for the given (realigned) civil-time value.
 //
 // Example:
 //
 //   absl::CivilDay a(2015, 8, 13);
 //   absl::Weekday wd = absl::GetWeekday(a);  // wd == absl::Weekday::thursday
 //
-inline Weekday GetWeekday(CivilDay cd) {
-  return time_internal::cctz::get_weekday(cd);
+inline Weekday GetWeekday(CivilSecond cs) {
+  return time_internal::cctz::get_weekday(cs);
 }
 
 // NextWeekday()
@@ -420,7 +420,7 @@ inline CivilDay PrevWeekday(CivilDay cd, Weekday wd) {
 
 // GetYearDay()
 //
-// Returns the day-of-year for the given absl::CivilDay.
+// Returns the day-of-year for the given (realigned) civil-time value.
 //
 // Example:
 //
@@ -429,8 +429,8 @@ inline CivilDay PrevWeekday(CivilDay cd, Weekday wd) {
 //   absl::CivilDay b(2015, 12, 31);
 //   int yd_dec_31 = absl::GetYearDay(b);  // yd_dec_31 = 365
 //
-inline int GetYearDay(CivilDay cd) {
-  return time_internal::cctz::get_yearday(cd);
+inline int GetYearDay(CivilSecond cs) {
+  return time_internal::cctz::get_yearday(cs);
 }
 
 // FormatCivilTime()
diff --git a/absl/time/civil_time_test.cc b/absl/time/civil_time_test.cc
index 070f0d573823..03cd1f12d563 100644
--- a/absl/time/civil_time_test.cc
+++ b/absl/time/civil_time_test.cc
@@ -616,6 +616,8 @@ TEST(CivilTime, Properties) {
   EXPECT_EQ(4, ss.hour());
   EXPECT_EQ(5, ss.minute());
   EXPECT_EQ(6, ss.second());
+  EXPECT_EQ(absl::Weekday::tuesday, absl::GetWeekday(ss));
+  EXPECT_EQ(34, absl::GetYearDay(ss));
 
   absl::CivilMinute mm(2015, 2, 3, 4, 5, 6);
   EXPECT_EQ(2015, mm.year());
@@ -624,6 +626,8 @@ TEST(CivilTime, Properties) {
   EXPECT_EQ(4, mm.hour());
   EXPECT_EQ(5, mm.minute());
   EXPECT_EQ(0, mm.second());
+  EXPECT_EQ(absl::Weekday::tuesday, absl::GetWeekday(mm));
+  EXPECT_EQ(34, absl::GetYearDay(mm));
 
   absl::CivilHour hh(2015, 2, 3, 4, 5, 6);
   EXPECT_EQ(2015, hh.year());
@@ -632,6 +636,8 @@ TEST(CivilTime, Properties) {
   EXPECT_EQ(4, hh.hour());
   EXPECT_EQ(0, hh.minute());
   EXPECT_EQ(0, hh.second());
+  EXPECT_EQ(absl::Weekday::tuesday, absl::GetWeekday(hh));
+  EXPECT_EQ(34, absl::GetYearDay(hh));
 
   absl::CivilDay d(2015, 2, 3, 4, 5, 6);
   EXPECT_EQ(2015, d.year());
@@ -640,6 +646,8 @@ TEST(CivilTime, Properties) {
   EXPECT_EQ(0, d.hour());
   EXPECT_EQ(0, d.minute());
   EXPECT_EQ(0, d.second());
+  EXPECT_EQ(absl::Weekday::tuesday, absl::GetWeekday(d));
+  EXPECT_EQ(34, absl::GetYearDay(d));
 
   absl::CivilMonth m(2015, 2, 3, 4, 5, 6);
   EXPECT_EQ(2015, m.year());
@@ -648,6 +656,8 @@ TEST(CivilTime, Properties) {
   EXPECT_EQ(0, m.hour());
   EXPECT_EQ(0, m.minute());
   EXPECT_EQ(0, m.second());
+  EXPECT_EQ(absl::Weekday::sunday, absl::GetWeekday(m));
+  EXPECT_EQ(32, absl::GetYearDay(m));
 
   absl::CivilYear y(2015, 2, 3, 4, 5, 6);
   EXPECT_EQ(2015, y.year());
@@ -656,6 +666,8 @@ TEST(CivilTime, Properties) {
   EXPECT_EQ(0, y.hour());
   EXPECT_EQ(0, y.minute());
   EXPECT_EQ(0, y.second());
+  EXPECT_EQ(absl::Weekday::thursday, absl::GetWeekday(y));
+  EXPECT_EQ(1, absl::GetYearDay(y));
 }
 
 TEST(CivilTime, Format) {
diff --git a/absl/time/internal/cctz/include/cctz/civil_time_detail.h b/absl/time/internal/cctz/include/cctz/civil_time_detail.h
index 0dcb1ad46ba2..433078a73097 100644
--- a/absl/time/internal/cctz/include/cctz/civil_time_detail.h
+++ b/absl/time/internal/cctz/include/cctz/civil_time_detail.h
@@ -535,8 +535,7 @@ enum class weekday {
   sunday,
 };
 
-template <typename T>
-CONSTEXPR_F weekday get_weekday(const civil_time<T>& ct) noexcept {
+CONSTEXPR_F weekday get_weekday(const civil_second& cs) noexcept {
   CONSTEXPR_D weekday k_weekday_by_mon_off[13] = {
       weekday::monday,    weekday::tuesday,  weekday::wednesday,
       weekday::thursday,  weekday::friday,   weekday::saturday,
@@ -547,9 +546,9 @@ CONSTEXPR_F weekday get_weekday(const civil_time<T>& ct) noexcept {
   CONSTEXPR_D int k_weekday_offsets[1 + 12] = {
       -1, 0, 3, 2, 5, 0, 3, 5, 1, 4, 6, 2, 4,
   };
-  year_t wd = 2400 + (ct.year() % 400) - (ct.month() < 3);
+  year_t wd = 2400 + (cs.year() % 400) - (cs.month() < 3);
   wd += wd / 4 - wd / 100 + wd / 400;
-  wd += k_weekday_offsets[ct.month()] + ct.day();
+  wd += k_weekday_offsets[cs.month()] + cs.day();
   return k_weekday_by_mon_off[wd % 7 + 6];
 }
 
@@ -595,13 +594,12 @@ CONSTEXPR_F civil_day prev_weekday(civil_day cd, weekday wd) noexcept {
   }
 }
 
-template <typename T>
-CONSTEXPR_F int get_yearday(const civil_time<T>& ct) noexcept {
+CONSTEXPR_F int get_yearday(const civil_second& cs) noexcept {
   CONSTEXPR_D int k_month_offsets[1 + 12] = {
       -1, 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334,
   };
-  const int feb29 = (ct.month() > 2 && impl::is_leap_year(ct.year()));
-  return k_month_offsets[ct.month()] + feb29 + ct.day();
+  const int feb29 = (cs.month() > 2 && impl::is_leap_year(cs.year()));
+  return k_month_offsets[cs.month()] + feb29 + cs.day();
 }
 
 ////////////////////////////////////////////////////////////////////////
diff --git a/absl/time/internal/cctz/src/time_zone_info.cc b/absl/time/internal/cctz/src/time_zone_info.cc
index 184bd434c2d2..72bb3bde8eae 100644
--- a/absl/time/internal/cctz/src/time_zone_info.cc
+++ b/absl/time/internal/cctz/src/time_zone_info.cc
@@ -505,9 +505,9 @@ bool TimeZoneInfo::Load(const std::string& name, ZoneInfoSource* zip) {
   if (tzh.tzh_version[0] != '\0') {
     // Snarf up the NL-enclosed future POSIX spec. Note
     // that version '3' files utilize an extended format.
-    auto get_char = [](ZoneInfoSource* zip) -> int {
+    auto get_char = [](ZoneInfoSource* azip) -> int {
       unsigned char ch;  // all non-EOF results are positive
-      return (zip->Read(&ch, 1) == 1) ? ch : EOF;
+      return (azip->Read(&ch, 1) == 1) ? ch : EOF;
     };
     if (get_char(zip) != '\n')
       return false;
diff --git a/absl/time/time.cc b/absl/time/time.cc
index 338c4523d1b1..6a387bcee61f 100644
--- a/absl/time/time.cc
+++ b/absl/time/time.cc
@@ -457,8 +457,7 @@ struct tm ToTM(absl::Time t, absl::TimeZone tz) {
     tm.tm_year = static_cast<int>(cs.year() - 1900);
   }
 
-  const CivilDay cd(cs);
-  switch (GetWeekday(cd)) {
+  switch (GetWeekday(cs)) {
     case Weekday::sunday:
       tm.tm_wday = 0;
       break;
@@ -481,7 +480,7 @@ struct tm ToTM(absl::Time t, absl::TimeZone tz) {
       tm.tm_wday = 6;
       break;
   }
-  tm.tm_yday = GetYearDay(cd) - 1;
+  tm.tm_yday = GetYearDay(cs) - 1;
   tm.tm_isdst = ci.is_dst ? 1 : 0;
 
   return tm;
diff --git a/absl/time/time_test.cc b/absl/time/time_test.cc
index e2b2f8097021..37af39d99830 100644
--- a/absl/time/time_test.cc
+++ b/absl/time/time_test.cc
@@ -112,7 +112,7 @@ TEST(Time, UnixEpoch) {
   const auto ci = absl::UTCTimeZone().At(absl::UnixEpoch());
   EXPECT_EQ(absl::CivilSecond(1970, 1, 1, 0, 0, 0), ci.cs);
   EXPECT_EQ(absl::ZeroDuration(), ci.subsecond);
-  EXPECT_EQ(absl::Weekday::thursday, absl::GetWeekday(absl::CivilDay(ci.cs)));
+  EXPECT_EQ(absl::Weekday::thursday, absl::GetWeekday(ci.cs));
 }
 
 TEST(Time, Breakdown) {
@@ -123,14 +123,14 @@ TEST(Time, Breakdown) {
   auto ci = tz.At(t);
   EXPECT_CIVIL_INFO(ci, 1969, 12, 31, 19, 0, 0, -18000, false);
   EXPECT_EQ(absl::ZeroDuration(), ci.subsecond);
-  EXPECT_EQ(absl::Weekday::wednesday, absl::GetWeekday(absl::CivilDay(ci.cs)));
+  EXPECT_EQ(absl::Weekday::wednesday, absl::GetWeekday(ci.cs));
 
   // Just before the epoch.
   t -= absl::Nanoseconds(1);
   ci = tz.At(t);
   EXPECT_CIVIL_INFO(ci, 1969, 12, 31, 18, 59, 59, -18000, false);
   EXPECT_EQ(absl::Nanoseconds(999999999), ci.subsecond);
-  EXPECT_EQ(absl::Weekday::wednesday, absl::GetWeekday(absl::CivilDay(ci.cs)));
+  EXPECT_EQ(absl::Weekday::wednesday, absl::GetWeekday(ci.cs));
 
   // Some time later.
   t += absl::Hours(24) * 2735;
@@ -139,7 +139,7 @@ TEST(Time, Breakdown) {
   ci = tz.At(t);
   EXPECT_CIVIL_INFO(ci, 1977, 6, 28, 14, 30, 15, -14400, true);
   EXPECT_EQ(8, ci.subsecond / absl::Nanoseconds(1));
-  EXPECT_EQ(absl::Weekday::tuesday, absl::GetWeekday(absl::CivilDay(ci.cs)));
+  EXPECT_EQ(absl::Weekday::tuesday, absl::GetWeekday(ci.cs));
 }
 
 TEST(Time, AdditiveOperators) {
@@ -979,15 +979,15 @@ TEST(Time, ConversionSaturation) {
   EXPECT_CIVIL_INFO(ci, std::numeric_limits<int64_t>::max(), 12, 31, 23,
                             59, 59, 0, false);
   EXPECT_EQ(absl::InfiniteDuration(), ci.subsecond);
-  EXPECT_EQ(absl::Weekday::thursday, absl::GetWeekday(absl::CivilDay(ci.cs)));
-  EXPECT_EQ(365, absl::GetYearDay(absl::CivilDay(ci.cs)));
+  EXPECT_EQ(absl::Weekday::thursday, absl::GetWeekday(ci.cs));
+  EXPECT_EQ(365, absl::GetYearDay(ci.cs));
   EXPECT_STREQ("-00", ci.zone_abbr);  // artifact of TimeZone::At()
   ci = utc.At(absl::InfinitePast());
   EXPECT_CIVIL_INFO(ci, std::numeric_limits<int64_t>::min(), 1, 1, 0, 0,
                             0, 0, false);
   EXPECT_EQ(-absl::InfiniteDuration(), ci.subsecond);
-  EXPECT_EQ(absl::Weekday::sunday, absl::GetWeekday(absl::CivilDay(ci.cs)));
-  EXPECT_EQ(1, absl::GetYearDay(absl::CivilDay(ci.cs)));
+  EXPECT_EQ(absl::Weekday::sunday, absl::GetWeekday(ci.cs));
+  EXPECT_EQ(1, absl::GetYearDay(ci.cs));
   EXPECT_STREQ("-00", ci.zone_abbr);  // artifact of TimeZone::At()
 
   // Approach the maximal Time value from below.