summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2022-12-01 21:47:38 +0100
committerCarl Hetherington <cth@carlh.net>2022-12-13 21:57:52 +0100
commit71dc0132d52f476f929ef222a3264dd9fc7e04a4 (patch)
tree8615dfe10e75c7fbfc486cba1c783c9db197f17a
parent6fbba420657d893a5da770af20364af4d689d4b7 (diff)
Add missing operator.
-rw-r--r--src/local_time.cc24
-rw-r--r--src/local_time.h1
2 files changed, 25 insertions, 0 deletions
diff --git a/src/local_time.cc b/src/local_time.cc
index 1bedb9bd..727583e5 100644
--- a/src/local_time.cc
+++ b/src/local_time.cc
@@ -303,6 +303,30 @@ LocalTime::operator< (LocalTime const & other) const
bool
+LocalTime::operator>(LocalTime const & other) const
+{
+ DCP_ASSERT(_offset == other._offset);
+
+ if (_year != other._year) {
+ return _year > other._year;
+ }
+ if (_month != other._month) {
+ return _month > other._month;
+ }
+ if (_day != other._day) {
+ return _day > other._day;
+ }
+ if (_hour != other._hour) {
+ return _hour > other._hour;
+ }
+ if (_second != other._second) {
+ return _second > other._second;
+ }
+ return _millisecond > other._millisecond;
+}
+
+
+bool
LocalTime::operator!= (LocalTime const & other) const
{
return !(*this == other);
diff --git a/src/local_time.h b/src/local_time.h
index 58acc227..9a19b2d5 100644
--- a/src/local_time.h
+++ b/src/local_time.h
@@ -138,6 +138,7 @@ public:
bool operator== (LocalTime const & other) const;
bool operator!= (LocalTime const & other) const;
bool operator< (LocalTime const & other) const;
+ bool operator>(LocalTime const & other) const;
private:
friend struct ::local_time_basic_test;