Add Time::to_seconds.
authorCarl Hetherington <cth@carlh.net>
Sun, 11 Jan 2015 14:14:47 +0000 (14:14 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 11 Jan 2015 14:14:47 +0000 (14:14 +0000)
src/dcp_time.cc
src/dcp_time.h

index 83a7f2bbf37f01699c37de357243a97a85c1589e..93c12a064d778182ef88dfa50ffa833ca066f7d5 100644 (file)
@@ -43,6 +43,11 @@ Time::Time (int frame, int frames_per_second, int tcr_)
        set (double (frame) / frames_per_second, tcr);
 }
 
+Time::Time (double seconds)
+{
+       set (seconds, 24);
+}
+
 void
 Time::set (double seconds, int tcr_)
 {
@@ -248,3 +253,9 @@ Time::to_editable_units (int tcr_) const
 {
        return (int64_t(e) * float (tcr_ / tcr)) + int64_t(s) * tcr_ + int64_t(m) * 60 * tcr_ + int64_t(h) * 60 * 60 * tcr_;
 }
+
+double
+Time::to_seconds () const
+{
+       return h * 3600 + m * 60 + s + double(e) / tcr;
+}
index 23f860cf084fb678a6c79e8eb327cf419d2dd53d..c7391e636ced139bddd3c537487afd4f04ad9baa 100644 (file)
@@ -59,6 +59,8 @@ public:
                , tcr (tcr_)
        {}
 
+       Time (double seconds);
+
        Time (std::string time, int tcr);
 
        int h; ///<   hours
@@ -68,6 +70,7 @@ public:
        int tcr; ///< timecode rate: the number of editable units per second.
 
        std::string to_string () const;
+       double to_seconds () const;
        int64_t to_editable_units (int tcr_) const;
 
 private: