Add operator<= for HMSF.
[dcpomatic.git] / src / lib / dcpomatic_time.cc
index 4f6c9b664e3c0ad28a7068f7cb5b03654ed77676..60fc5342a33437414fec6f1b76ad38086320324c 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2014-2016 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2014-2021 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
 
 */
 
+
 #include "dcpomatic_time.h"
 #include <inttypes.h>
 
+
 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))
+       : _t (llrint(d.get() * f.speed_up))
 {
 
 }
 
+
 template <>
 Time<DCPTimeDifferentiator, ContentTimeDifferentiator>::Time (ContentTime d, FrameRateChange f)
-       : _t (llrint (d.get() / f.speed_up))
+       : _t (llrint(d.get() / f.speed_up))
 {
 
 }
 
+
 DCPTime
-min (DCPTime a, DCPTime b)
+dcpomatic::min (DCPTime a, DCPTime b)
 {
        if (a < b) {
                return a;
@@ -47,8 +72,9 @@ min (DCPTime a, DCPTime b)
        return b;
 }
 
+
 DCPTime
-max (DCPTime a, DCPTime b)
+dcpomatic::max (DCPTime a, DCPTime b)
 {
        if (a > b) {
                return a;
@@ -57,8 +83,9 @@ max (DCPTime a, DCPTime b)
        return b;
 }
 
+
 ContentTime
-min (ContentTime a, ContentTime b)
+dcpomatic::min (ContentTime a, ContentTime b)
 {
        if (a < b) {
                return a;
@@ -67,8 +94,9 @@ min (ContentTime a, ContentTime b)
        return b;
 }
 
+
 ContentTime
-max (ContentTime a, ContentTime b)
+dcpomatic::max (ContentTime a, ContentTime b)
 {
        if (a > b) {
                return a;
@@ -77,8 +105,9 @@ max (ContentTime a, ContentTime b)
        return b;
 }
 
+
 string
-to_string (ContentTime t)
+dcpomatic::to_string (ContentTime t)
 {
        char buffer[64];
 #ifdef DCPOMATIC_WINDOWS
@@ -89,8 +118,9 @@ to_string (ContentTime t)
        return buffer;
 }
 
+
 string
-to_string (DCPTime t)
+dcpomatic::to_string (DCPTime t)
 {
        char buffer[64];
 #ifdef DCPOMATIC_WINDOWS
@@ -101,8 +131,9 @@ to_string (DCPTime t)
        return buffer;
 }
 
+
 string
-to_string (DCPTimePeriod p)
+dcpomatic::to_string (DCPTimePeriod p)
 {
        char buffer[64];
 #ifdef DCPOMATIC_WINDOWS