diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/sub_time.cc | 10 | ||||
| -rw-r--r-- | src/sub_time.h | 2 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/sub_time.cc b/src/sub_time.cc index e304310..3f4d1e9 100644 --- a/src/sub_time.cc +++ b/src/sub_time.cc @@ -152,3 +152,13 @@ Time::from_hms (int h, int m, int s, int ms) { return Time (h * 3600 + m * 60 + s, ms, Rational (1000, 1)); } + +double +Time::all_as_seconds () const +{ + if (!_rate) { + throw UnknownFrameRateError (); + } + + return _seconds + double (_frames) / _rate.get().fraction (); +} diff --git a/src/sub_time.h b/src/sub_time.h index 7e1d193..22178e9 100644 --- a/src/sub_time.h +++ b/src/sub_time.h @@ -55,6 +55,8 @@ public: int frames_at (Rational rate) const; int milliseconds () const; + double all_as_seconds () const; + static Time from_hmsf (int h, int m, int s, int f, boost::optional<Rational> rate = boost::optional<Rational> ()); static Time from_hms (int h, int m, int s, int ms); |
