return float (at) / bt;
}
-/** @return A string of the form h:m:s:e */
+/** @return A string of the form h:m:s:e padded as in 00:00:00:000 */
string
Time::to_string () const
{
stringstream str;
- str << h << ":" << m << ":" << s << ":" << e;
+ str << setw(2) << setfill('0') << h << ":"
+ << setw(2) << setfill('0') << m << ":"
+ << setw(2) << setfill('0') << s << ":"
+ << setw(3) << setfill('0') << e;
return str.str ();
}
{
return h * 3600 + m * 60 + s + double(e) / tcr;
}
+
+Time
+Time::rebase (int tcr_) const
+{
+ return Time (h, m, s, rint (float (e) * tcr_ / tcr), tcr_);
+}
BOOST_CHECK_EQUAL (t.s, 34);
BOOST_CHECK_EQUAL (t.m, 18);
BOOST_CHECK_EQUAL (t.h, 11);
- BOOST_CHECK_EQUAL (t.to_string(), "11:18:34:73");
+ BOOST_CHECK_EQUAL (t.to_string(), "11:18:34:073");
/* Use a tcr of 24 so that the editable event is a frame */
dcp::Time a (3, 2, 3, 4, 24);
BOOST_CHECK_EQUAL (r.m, 58);
BOOST_CHECK_EQUAL (r.s, 58);
BOOST_CHECK_EQUAL (r.e, 23);
- BOOST_CHECK_EQUAL (r.to_string(), "0:58:58:23");
+ BOOST_CHECK_EQUAL (r.to_string(), "00:58:58:023");
/* Different tcr (25) */
a = dcp::Time (1, 58, 56, 2, 25);
BOOST_CHECK_EQUAL (r.m, 6);
BOOST_CHECK_EQUAL (r.s, 8);
BOOST_CHECK_EQUAL (r.e, 3);
- BOOST_CHECK_EQUAL (r.to_string(), "3:6:8:3");
+ BOOST_CHECK_EQUAL (r.to_string(), "03:06:08:003");
/* Another arbitrary tcr (30) */
a = dcp::Time (24, 12, 6, 3, 30);
b = dcp::Time (0, 0, 0, 4, 48);
r = a + b;
BOOST_CHECK_EQUAL (r, dcp::Time (0, 0, 0, 240, 1152));
+
+ /* Check rebase() */
+ a = dcp::Time (1, 58, 56, 2, 25);
+ BOOST_CHECK_EQUAL (a.rebase (250), dcp::Time (1, 58, 56, 20, 250));
+ b = dcp::Time (9, 12, 41, 17, 99);
+ BOOST_CHECK_EQUAL (b.rebase (250), dcp::Time (9, 12, 41, 43, 250));
}
" <ReelNumber>1</ReelNumber>\n"
" <Language>EN</Language>\n"
" <Font Id=\"Frutiger\" Italic=\"no\" Color=\"FFFFFFFF\" Size=\"48\" Effect=\"none\" EffectColor=\"FF000000\" Script=\"normal\" Underlined=\"no\" Weight=\"normal\">\n"
- " <Subtitle SpotNumber=\"1\" TimeIn=\"0:4:9:22\" TimeOut=\"0:4:11:22\" FadeUpTime=\"0\" FadeDownTime=\"0\">\n"
+ " <Subtitle SpotNumber=\"1\" TimeIn=\"00:04:09:022\" TimeOut=\"00:04:11:022\" FadeUpTime=\"0\" FadeDownTime=\"0\">\n"
" <Text VAlign=\"top\" VPosition=\"80\">Hello world</Text>\n"
" </Subtitle>\n"
" </Font>\n"
" <Font Italic=\"yes\" Color=\"FF800040\" Size=\"91\" Effect=\"border\" EffectColor=\"FF010203\" Script=\"normal\" Underlined=\"no\" Weight=\"normal\">\n"
- " <Subtitle SpotNumber=\"2\" TimeIn=\"5:41:0:21\" TimeOut=\"6:12:15:21\" FadeUpTime=\"930790\" FadeDownTime=\"4591830\">\n"
+ " <Subtitle SpotNumber=\"2\" TimeIn=\"05:41:00:021\" TimeOut=\"06:12:15:021\" FadeUpTime=\"930790\" FadeDownTime=\"4591830\">\n"
" <Text VAlign=\"bottom\" VPosition=\"40\">What's going on</Text>\n"
" </Subtitle>\n"
" </Font>\n"