summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2023-12-20 23:41:35 +0100
committerCarl Hetherington <cth@carlh.net>2024-03-12 23:41:00 +0100
commit9936ec84cb2a5e5f8f4fe77bcd5742f06bdb2d6c (patch)
tree95d48e9cd856b2c92d14e7b91da3ab1f0d49bdda
parent521424e747dced3ade9600fc62c48526e199ef16 (diff)
Add operator<= for HMSF.
-rw-r--r--src/lib/dcpomatic_time.cc19
-rw-r--r--src/lib/dcpomatic_time.h3
2 files changed, 22 insertions, 0 deletions
diff --git a/src/lib/dcpomatic_time.cc b/src/lib/dcpomatic_time.cc
index ac797f8f4..60fc5342a 100644
--- a/src/lib/dcpomatic_time.cc
+++ b/src/lib/dcpomatic_time.cc
@@ -27,6 +27,25 @@ using std::string;
using namespace dcpomatic;
+bool
+dcpomatic::operator<=(HMSF const& a, HMSF const& b)
+{
+ if (a.h != b.h) {
+ return a.h <= b.h;
+ }
+
+ if (a.m != b.m) {
+ return a.m <= b.m;
+ }
+
+ if (a.s != b.s) {
+ return a.s <= b.s;
+ }
+
+ return a.f <= b.f;
+}
+
+
template <>
Time<ContentTimeDifferentiator, DCPTimeDifferentiator>::Time (DCPTime d, FrameRateChange f)
: _t (llrint(d.get() * f.speed_up))
diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h
index 9ebb334fe..63bb86549 100644
--- a/src/lib/dcpomatic_time.h
+++ b/src/lib/dcpomatic_time.h
@@ -64,6 +64,9 @@ public:
};
+bool operator<=(HMSF const& a, HMSF const& b);
+
+
/** A time in seconds, expressed as a number scaled up by Time::HZ. We want two different
* versions of this class, dcpomatic::ContentTime and dcpomatic::DCPTime, and we want it to be impossible to
* convert implicitly between the two. Hence there's this template hack. I'm not