}
// converts ISO-DATE: 2003-06-13
-int date_to_seconds(const std::string &date)
+time_t date_to_seconds(const std::string &date)
{
- int rtn = -1, year = -1, month = -1, day = -1;
+ time_t rtn = 0;
+ int year = -1, month = -1, day = -1;
string::size_type pos = date.find("-");
if (pos == string::npos)
double prec_time(void);
-int date_to_seconds(const std::string &date);
+time_t date_to_seconds(const std::string &date);
std::string make_nice_time(int seconds);
std::string format_full_time(time_t seconds);
BOOST_CHECK_EQUAL("17.10.2011 11:33", format_full_time(seconds));
}
+BOOST_AUTO_TEST_CASE(DateToSeconds1)
+{
+ // no DST
+ BOOST_CHECK_EQUAL(1325372400, date_to_seconds("2012-01-01"));
+}
+
+BOOST_AUTO_TEST_CASE(DateToSeconds2)
+{
+ // DST
+ BOOST_CHECK_EQUAL(1341093600, date_to_seconds("2012-07-01"));
+}
+
+
BOOST_AUTO_TEST_SUITE_END()