diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-06-06 08:59:53 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-06-06 08:59:53 +0100 |
| commit | aba52dd5cc2fa9736fd9b007962923d4dae8c4a6 (patch) | |
| tree | aa206963eaf22e3be47d9a10f83553cfb57879fc /src/sub_time.cc | |
| parent | a06e701131b813bc42ae81b9c5e8c7dbbfea7eb9 (diff) | |
Hacks.libssa
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 |
