about summary refs log tree commit diff
path: root/absl/time
diff options
context:
space:
mode:
authorAbseil Team <absl-team@google.com>2018-10-12T13·53-0700
committerCJ Johnson <johnsoncj@google.com>2018-10-12T14·26-0400
commita00bdd176d66ef0b417d9576052a19091fbdf891 (patch)
tree9066ed8bdf727ef9f95db60ec44a7132224cf64b /absl/time
parentf340f773edab951656b19b6f1a77c964a78ec4c2 (diff)
Export of internal Abseil changes.
--
fa894a667a3bebbe479539c8d5e829beebf36c27 by Abseil Team <absl-team@google.com>:

Import of CCTZ from GitHub.

PiperOrigin-RevId: 216855907

--
59e0a42fa9045eb164573b82ce625248bd9999f3 by Jon Cohen <cohenjon@google.com>:

Some edits to the documentation for absl::Hash as I was reading through it.

Itemized changes:
  * implement -> implements for grammar
  * Fix an incomplete sentence
  * specify *any* type T as opposed to *a* type T ? this is just the language I tend to see for these sorts of concepts in math and makes it more clear that we?re talking about a set of all types T satisfying these constraints
  * add arguments to comine() and combine_contiguous() ? this was mostly because for hash_continuous there was a reference to `size` elements without any mention of what `size` was.

PiperOrigin-RevId: 216766923

--
c2a744d0f70ec5a079c22502b7a7ca72805a29dc by Shaindel Schwartz <shaindel@google.com>:

Remove unneeded include.

PiperOrigin-RevId: 216703710

--
ad22fc4e3d236f7bd354b61e0fa37ea524a7cf5e by Shaindel Schwartz <shaindel@google.com>:

Fix typos.

PiperOrigin-RevId: 216699071
GitOrigin-RevId: fa894a667a3bebbe479539c8d5e829beebf36c27
Change-Id: I35c8d8be66043aad9f17bbb867e69acb770bd1b0
Diffstat (limited to 'absl/time')
-rw-r--r--absl/time/civil_time.h1
-rw-r--r--absl/time/internal/cctz/src/time_zone_libc.cc2
-rw-r--r--absl/time/internal/cctz/src/time_zone_lookup_test.cc10
3 files changed, 11 insertions, 2 deletions
diff --git a/absl/time/civil_time.h b/absl/time/civil_time.h
index a1f553059939..f6f76cd65cda 100644
--- a/absl/time/civil_time.h
+++ b/absl/time/civil_time.h
@@ -73,7 +73,6 @@
 
 #include <string>
 
-#include "absl/base/port.h"  // Needed for string vs std::string
 #include "absl/strings/string_view.h"
 #include "absl/time/internal/cctz/include/cctz/civil_time.h"
 
diff --git a/absl/time/internal/cctz/src/time_zone_libc.cc b/absl/time/internal/cctz/src/time_zone_libc.cc
index 074c8d0a4a40..e35fa18b7733 100644
--- a/absl/time/internal/cctz/src/time_zone_libc.cc
+++ b/absl/time/internal/cctz/src/time_zone_libc.cc
@@ -111,7 +111,7 @@ time_zone::absolute_lookup TimeZoneLibC::BreakTime(
     al.offset = 0;
     al.abbr = "UTC";
   }
-  al.cs = civil_second(tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+  al.cs = civil_second(tm.tm_year + year_t{1900}, tm.tm_mon + 1, tm.tm_mday,
                        tm.tm_hour, tm.tm_min, tm.tm_sec);
   al.is_dst = tm.tm_isdst > 0;
   return al;
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 551292fb55e0..280c96b4f207 100644
--- a/absl/time/internal/cctz/src/time_zone_lookup_test.cc
+++ b/absl/time/internal/cctz/src/time_zone_lookup_test.cc
@@ -990,6 +990,16 @@ TEST(MakeTime, SysSecondsLimits) {
   EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::min(), tp);
   tp = convert(civil_second::min(), west);
   EXPECT_EQ(time_point<absl::time_internal::cctz::seconds>::min(), tp);
+
+  // Checks that "tm_year + 1900", as used by the "libc" implementation,
+  // can produce year values beyond the range on an int without overflow.
+#if defined(_WIN32) || defined(_WIN64)
+  // localtime_s() and gmtime_s() don't believe in years past 3000.
+#else
+  const time_zone libc_utc = LoadZone("libc:UTC");
+  tp = convert(civil_year(year_t{2147483648}), libc_utc);
+  EXPECT_EQ("2147483648-01-01T00:00:00+00:00", format(RFC3339, tp, libc_utc));
+#endif
 }
 
 TEST(NextTransition, UTC) {