2 Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20 #ifndef LIBSUB_SUB_TIME_H
21 #define LIBSUB_SUB_TIME_H
24 #include <boost/optional.hpp>
40 int frames_at (Rational rate) const;
41 int milliseconds () const;
43 double all_as_seconds () const;
48 static Time from_hmsf (int h, int m, int s, int f, boost::optional<Rational> rate = boost::optional<Rational> ());
49 static Time from_hms (int h, int m, int s, int ms);
50 static Time from_frames (int frames, Rational rate);
53 friend bool operator< (Time const & a, Time const & b);
54 friend bool operator> (Time const & a, Time const & b);
55 friend bool operator== (Time const & a, Time const & b);
56 friend std::ostream& operator<< (std::ostream& s, Time const & t);
58 Time (int seconds, int frames, boost::optional<Rational> rate)
66 boost::optional<Rational> _rate;
69 bool operator< (Time const & a, Time const & b);
70 bool operator> (Time const & a, Time const & b);
71 bool operator== (Time const & a, Time const & b);
72 bool operator!= (Time const & a, Time const & b);
73 std::ostream& operator<< (std::ostream& s, Time const & t);