diff options
Diffstat (limited to 'src/sub_time.cc')
| -rw-r--r-- | src/sub_time.cc | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/sub_time.cc b/src/sub_time.cc index c4e00ba..1c7d294 100644 --- a/src/sub_time.cc +++ b/src/sub_time.cc @@ -155,6 +155,12 @@ Time::from_hms (int h, int m, int s, int ms) return Time (h * 3600 + m * 60 + s, ms, Rational (1000, 1)); } +Time +Time::from_milliseconds (int64_t m) +{ + return Time (m / 1000, m % 1000, Rational (1000, 1)); +} + /** Create a Time from a number of frames. * rate must be integer. */ @@ -172,11 +178,9 @@ Time::all_as_seconds () const return _seconds + double(milliseconds ()) / 1000; } -/** Add a time to this one. This time must have an integer _rate - * and t must have the same rate. - */ -void -Time::add (Time t) +/** This time must have an integer _rate and t must have the same rate */ +Time & +Time::operator+= (Time const & t) { SUB_ASSERT (_rate); @@ -190,6 +194,17 @@ Time::add (Time t) _frames -= _rate.get().integer_fraction(); ++_seconds; } + + return *this; +} + +/** This time must have an integer _rate and t must have the same rate */ +Time +Time::operator+ (Time const & t) +{ + Time r = *this; + r += t; + return r; } void |
