one more time_t fix, the other functions look good
authorGerd von Egidy <gerd.von.egidy@intra2net.com>
Fri, 10 Feb 2012 12:28:03 +0000 (13:28 +0100)
committerGerd von Egidy <gerd.von.egidy@intra2net.com>
Fri, 10 Feb 2012 12:28:03 +0000 (13:28 +0100)
src/timefunc.cpp
src/timefunc.hxx
test/test_timefunc.cpp

index 1288301..e956ee3 100644 (file)
@@ -69,9 +69,10 @@ double prec_time(void)
 }
 
 // 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)
index 8db994c..96530b4 100644 (file)
@@ -33,7 +33,7 @@ on this file might be covered by the GNU General Public License.
 
 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);
index f4bc4f2..58dcaf5 100644 (file)
@@ -449,4 +449,17 @@ BOOST_AUTO_TEST_CASE(FormatFullTime)
     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()