From 78db20ae144115e6eaea6e7bd239e0ec06baf082 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sun, 11 Jan 2015 14:14:47 +0000 Subject: Add Time::to_seconds. --- src/dcp_time.cc | 11 +++++++++++ src/dcp_time.h | 3 +++ 2 files changed, 14 insertions(+) (limited to 'src') diff --git a/src/dcp_time.cc b/src/dcp_time.cc index 83a7f2bb..93c12a06 100644 --- a/src/dcp_time.cc +++ b/src/dcp_time.cc @@ -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; +} diff --git a/src/dcp_time.h b/src/dcp_time.h index 23f860cf..c7391e63 100644 --- a/src/dcp_time.h +++ b/src/dcp_time.h @@ -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: -- cgit v1.2.3