about summary refs log tree commit diff
path: root/absl/time/time.h
diff options
context:
space:
mode:
Diffstat (limited to 'absl/time/time.h')
-rw-r--r--absl/time/time.h15
1 files changed, 15 insertions, 0 deletions
diff --git a/absl/time/time.h b/absl/time/time.h
index 2f0fda4cb07c..50bf971df0a2 100644
--- a/absl/time/time.h
+++ b/absl/time/time.h
@@ -163,6 +163,11 @@ class Duration {
   Duration& operator*=(float r) { return *this *= static_cast<double>(r); }
   Duration& operator/=(float r) { return *this /= static_cast<double>(r); }
 
+  template <typename H>
+  friend H AbslHashValue(H h, Duration d) {
+    return H::combine(std::move(h), d.rep_hi_, d.rep_lo_);
+  }
+
  private:
   friend constexpr int64_t time_internal::GetRepHi(Duration d);
   friend constexpr uint32_t time_internal::GetRepLo(Duration d);
@@ -611,6 +616,11 @@ class Time {
   // Returns the breakdown of this instant in the given TimeZone.
   Breakdown In(TimeZone tz) const;
 
+  template <typename H>
+  friend H AbslHashValue(H h, Time t) {
+    return H::combine(std::move(h), t.rep_);
+  }
+
  private:
   friend constexpr Time time_internal::FromUnixDuration(Duration d);
   friend constexpr Duration time_internal::ToUnixDuration(Time t);
@@ -1059,6 +1069,11 @@ class TimeZone {
 
   std::string name() const { return cz_.name(); }
 
+  template <typename H>
+  friend H AbslHashValue(H h, TimeZone tz) {
+    return H::combine(std::move(h), tz.cz_);
+  }
+
  private:
   friend bool operator==(TimeZone a, TimeZone b) { return a.cz_ == b.cz_; }
   friend bool operator!=(TimeZone a, TimeZone b) { return a.cz_ != b.cz_; }