summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2015-05-06 23:58:16 +0100
committerCarl Hetherington <cth@carlh.net>2015-05-06 23:58:16 +0100
commitc90ff0d85c88a18730787d511ebc7a6f6c21a2ba (patch)
treeba1fa1f807988dff7c7b95c3c2897b333182edd1 /src
parentac530d2eb8c8d4041e8265ab823a4b0373b27870 (diff)
Pad times with zeros; add Time::rebase().
Diffstat (limited to 'src')
-rw-r--r--src/dcp_time.cc13
-rw-r--r--src/dcp_time.h1
2 files changed, 12 insertions, 2 deletions
diff --git a/src/dcp_time.cc b/src/dcp_time.cc
index c3c60f66..8e152ad2 100644
--- a/src/dcp_time.cc
+++ b/src/dcp_time.cc
@@ -238,12 +238,15 @@ dcp::operator/ (Time a, Time const & b)
return float (at) / bt;
}
-/** @return A string of the form h:m:s:e */
+/** @return A string of the form h:m:s:e padded as in 00:00:00:000 */
string
Time::to_string () const
{
stringstream str;
- str << h << ":" << m << ":" << s << ":" << e;
+ str << setw(2) << setfill('0') << h << ":"
+ << setw(2) << setfill('0') << m << ":"
+ << setw(2) << setfill('0') << s << ":"
+ << setw(3) << setfill('0') << e;
return str.str ();
}
@@ -258,3 +261,9 @@ Time::to_seconds () const
{
return h * 3600 + m * 60 + s + double(e) / tcr;
}
+
+Time
+Time::rebase (int tcr_) const
+{
+ return Time (h, m, s, rint (float (e) * tcr_ / tcr), tcr_);
+}
diff --git a/src/dcp_time.h b/src/dcp_time.h
index c7391e63..907a8306 100644
--- a/src/dcp_time.h
+++ b/src/dcp_time.h
@@ -72,6 +72,7 @@ public:
std::string to_string () const;
double to_seconds () const;
int64_t to_editable_units (int tcr_) const;
+ Time rebase (int tcr_) const;
private:
void set (double seconds, int tcr);