summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-01-11 14:14:47 +0000
committerCarl Hetherington <cth@carlh.net>2015-01-11 14:14:47 +0000
commit78db20ae144115e6eaea6e7bd239e0ec06baf082 (patch)
treef68d3ceee83fc67f9a85cecc0c8a09b2f92790bb /src
parent67a414dc3826761c8933640e85560644f5f02310 (diff)
Add Time::to_seconds.
Diffstat (limited to 'src')
-rw-r--r--src/dcp_time.cc11
-rw-r--r--src/dcp_time.h3
2 files changed, 14 insertions, 0 deletions
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: