diff --git a/api/units/timestamp.h b/api/units/timestamp.h index af62b3b490..40f3e922ef 100644 --- a/api/units/timestamp.h +++ b/api/units/timestamp.h @@ -78,10 +78,18 @@ class Timestamp { bool operator!=(const Timestamp& other) const { return microseconds_ != other.microseconds_; } - bool operator<=(const Timestamp& other) const { return us() <= other.us(); } - bool operator>=(const Timestamp& other) const { return us() >= other.us(); } - bool operator>(const Timestamp& other) const { return us() > other.us(); } - bool operator<(const Timestamp& other) const { return us() < other.us(); } + bool operator<=(const Timestamp& other) const { + return microseconds_ <= other.microseconds_; + } + bool operator>=(const Timestamp& other) const { + return microseconds_ >= other.microseconds_; + } + bool operator>(const Timestamp& other) const { + return microseconds_ > other.microseconds_; + } + bool operator<(const Timestamp& other) const { + return microseconds_ < other.microseconds_; + } private: explicit Timestamp(int64_t us) : microseconds_(us) {} diff --git a/api/units/timestamp_unittest.cc b/api/units/timestamp_unittest.cc index 549a9c8e23..3b2770ceb3 100644 --- a/api/units/timestamp_unittest.cc +++ b/api/units/timestamp_unittest.cc @@ -46,6 +46,8 @@ TEST(TimestampTest, ComparisonOperators) { const int64_t kLarge = 451; EXPECT_EQ(Timestamp::Infinity(), Timestamp::Infinity()); + EXPECT_GE(Timestamp::Infinity(), Timestamp::Infinity()); + EXPECT_GT(Timestamp::Infinity(), Timestamp::ms(kLarge)); EXPECT_EQ(Timestamp::ms(kSmall), Timestamp::ms(kSmall)); EXPECT_LE(Timestamp::ms(kSmall), Timestamp::ms(kSmall)); EXPECT_GE(Timestamp::ms(kSmall), Timestamp::ms(kSmall));