diff options
| author | Carl Hetherington <cth@carlh.net> | 2015-05-06 23:58:16 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2015-05-06 23:58:16 +0100 |
| commit | c90ff0d85c88a18730787d511ebc7a6f6c21a2ba (patch) | |
| tree | ba1fa1f807988dff7c7b95c3c2897b333182edd1 /src/dcp_time.cc | |
| parent | ac530d2eb8c8d4041e8265ab823a4b0373b27870 (diff) | |
Pad times with zeros; add Time::rebase().
Diffstat (limited to 'src/dcp_time.cc')
| -rw-r--r-- | src/dcp_time.cc | 13 |
1 files changed, 11 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_); +} |
