From: Carl Hetherington Date: Fri, 14 Sep 2018 20:21:47 +0000 (+0100) Subject: Add operator< for LocalTime. X-Git-Tag: v1.6.2~40 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=ee05b1c06aa5305b5c97dc74dc8f253bab99a2ac;p=libdcp.git Add operator< for LocalTime. --- diff --git a/src/local_time.cc b/src/local_time.cc index 647ff35d..401bd9d7 100644 --- a/src/local_time.cc +++ b/src/local_time.cc @@ -212,6 +212,27 @@ LocalTime::operator== (LocalTime const & other) const _tz_hour == other._tz_hour && _tz_minute == other._tz_minute; } +bool +LocalTime::operator< (LocalTime const & other) const +{ + 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 { diff --git a/src/local_time.h b/src/local_time.h index d213b898..ad55ad5a 100644 --- a/src/local_time.h +++ b/src/local_time.h @@ -68,6 +68,7 @@ public: bool operator== (LocalTime const & other) const; bool operator!= (LocalTime const & other) const; + bool operator< (LocalTime const & other) const; private: friend class ::local_time_test;