2 Copyright (C) 2012-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 /** @file src/dcp_time.h
34 * @brief A representation of time within a DCP.
40 Time () : h (0), m (0), s (0), e (0), tcr (1) {}
42 /** Construct a Time from a frame index (starting from 0),
43 * a frames per second count and a timecode rate.
45 Time (int frame, int frames_per_second, int tcr);
47 /** Construct a Time from hours, minutes, seconds, editable units and a timecode rate.
51 * @param e_ Editable units (where 1 editable unit is 1 / tcr_ seconds)
52 * @param tcr_ Timecode rate; i.e. number of editable units per second.
54 Time (int h_, int m_, int s_, int e_, int tcr_)
62 Time (double seconds);
64 Time (std::string time, int tcr);
69 int e; ///< editable units (where 1 editable unit is 1 / tcr_ seconds)
70 int tcr; ///< timecode rate: the number of editable units per second.
72 std::string as_string () const;
73 double as_seconds () const;
74 int64_t as_editable_units (int tcr_) const;
75 Time rebase (int tcr_) const;
78 void set (double seconds, int tcr);
81 extern bool operator== (Time const & a, Time const & b);
82 extern bool operator!= (Time const & a, Time const & b);
83 extern bool operator<= (Time const & a, Time const & b);
84 extern bool operator< (Time const & a, Time const & b);
85 extern bool operator> (Time const & a, Time const & b);
86 extern bool operator>= (Time const & a, Time const & b);
87 extern std::ostream & operator<< (std::ostream & s, Time const & t);
88 extern Time operator+ (Time a, Time b);
89 extern Time operator- (Time a, Time b);
90 extern float operator/ (Time a, Time const & b);