*/
#include <iostream>
+#include <cmath>
#include "dcp_time.h"
using namespace std;
+using namespace libdcp;
+
+Time::Time (int frame, int frames_per_second)
+{
+ float sec_float = float (frame) / frames_per_second;
+ ms = int (sec_float * 1000) % 1000;
+ s = floor (sec_float);
+
+ if (s > 60) {
+ m = s / 60;
+ s -= m * 60;
+ }
+
+ if (m > 60) {
+ h = m / 60;
+ m -= h * 60;
+ }
+}
bool
libdcp::operator== (Time const & a, Time const & b)
{
public:
Time () : h (0), m (0), s (0), ms (0) {}
+ Time (int frame, int frames_per_second);
Time (int h_, int m_, int s_, int ms_)
: h (h_)
, m (m_)
BOOST_CHECK_EQUAL (subs.subtitles_at (libdcp::Time (0, 0, 14, 042)).front()->text(), "And these are Roy Hattersley's jeans");
}
-
+BOOST_AUTO_TEST_CASE (dcp_time)
+{
+ libdcp::Time t (977143, 24);
+
+ BOOST_CHECK_EQUAL (t.ms, 292);
+ BOOST_CHECK_EQUAL (t.s, 34);
+ BOOST_CHECK_EQUAL (t.m, 18);
+ BOOST_CHECK_EQUAL (t.h, 11);
+}