patched incorrect handling of struct tm in XmlRpc::XmlRpcValue
This commit is contained in:
parent
b9495ba094
commit
12e3b40235
11 changed files with 132 additions and 42 deletions
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.4 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.5 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/include/LiveSupport/Core/TimeConversion.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -70,8 +70,8 @@ using namespace LiveSupport;
|
|||
/**
|
||||
* A helper object holding static time conversion functions.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.4 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.5 $
|
||||
*/
|
||||
class TimeConversion
|
||||
{
|
||||
|
@ -111,6 +111,17 @@ class TimeConversion
|
|||
tmToPtime(const struct tm *time)
|
||||
throw (std::out_of_range);
|
||||
|
||||
/**
|
||||
* Convert a boost::posix_time::ptime to a struct tm,
|
||||
* with second precision.
|
||||
*
|
||||
* @param time the boost::posix_time::ptime to convert.
|
||||
* @return a struct tm, holding the same time.
|
||||
*/
|
||||
static void
|
||||
ptimeToTm(Ptr<ptime>::Ref convertFrom, struct tm & convertTo)
|
||||
throw ();
|
||||
|
||||
/**
|
||||
* Return the current time, with microsecond precision.
|
||||
*
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.5 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.6 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/TimeConversion.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -95,6 +95,25 @@ TimeConversion :: tmToPtime(const struct tm *time)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Convert a boost::ptime to a struct tm
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
TimeConversion :: ptimeToTm(Ptr<ptime>::Ref convertFrom, struct tm & convertTo)
|
||||
throw ()
|
||||
{
|
||||
date date = convertFrom->date();
|
||||
time_duration time = convertFrom->time_of_day();
|
||||
|
||||
convertTo.tm_year = date.year() - 1900;
|
||||
convertTo.tm_mon = date.month() - 1;
|
||||
convertTo.tm_mday = date.day();
|
||||
convertTo.tm_hour = time.hours();
|
||||
convertTo.tm_min = time.minutes();
|
||||
convertTo.tm_sec = time.seconds();
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Return the current time.
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.3 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/TimeConversionTest.cxx,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -143,6 +143,26 @@ TimeConversionTest :: tmToPtimeTest(void)
|
|||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test the ptimeToTm function
|
||||
*----------------------------------------------------------------------------*/
|
||||
void
|
||||
TimeConversionTest :: ptimeToTmTest(void)
|
||||
throw (CPPUNIT_NS::Exception)
|
||||
{
|
||||
struct tm tm;
|
||||
Ptr<ptime>::Ref ptime(new ptime(time_from_string("1770-12-17 10:20:30")));
|
||||
|
||||
TimeConversion::ptimeToTm(ptime, tm);
|
||||
CPPUNIT_ASSERT(tm.tm_year + 1900 == 1770);
|
||||
CPPUNIT_ASSERT(tm.tm_mon + 1 == 12);
|
||||
CPPUNIT_ASSERT(tm.tm_mday == 17);
|
||||
CPPUNIT_ASSERT(tm.tm_hour == 10);
|
||||
CPPUNIT_ASSERT(tm.tm_min == 20);
|
||||
CPPUNIT_ASSERT(tm.tm_sec == 30);
|
||||
}
|
||||
|
||||
|
||||
/*------------------------------------------------------------------------------
|
||||
* Test the now function
|
||||
*----------------------------------------------------------------------------*/
|
||||
|
|
|
@ -21,8 +21,8 @@
|
|||
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
|
||||
|
||||
Author : $Author: maroy $
|
||||
Version : $Revision: 1.3 $
|
||||
Author : $Author: fgerlits $
|
||||
Version : $Revision: 1.4 $
|
||||
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/core/src/TimeConversionTest.h,v $
|
||||
|
||||
------------------------------------------------------------------------------*/
|
||||
|
@ -57,8 +57,8 @@ namespace Core {
|
|||
/**
|
||||
* Unit test for the TimeConversion class.
|
||||
*
|
||||
* @author $Author: maroy $
|
||||
* @version $Revision: 1.3 $
|
||||
* @author $Author: fgerlits $
|
||||
* @version $Revision: 1.4 $
|
||||
* @see TimeConversion
|
||||
*/
|
||||
class TimeConversionTest : public CPPUNIT_NS::TestFixture
|
||||
|
@ -66,6 +66,7 @@ class TimeConversionTest : public CPPUNIT_NS::TestFixture
|
|||
CPPUNIT_TEST_SUITE(TimeConversionTest);
|
||||
CPPUNIT_TEST(timevalToPtimeTest);
|
||||
CPPUNIT_TEST(tmToPtimeTest);
|
||||
CPPUNIT_TEST(ptimeToTmTest);
|
||||
CPPUNIT_TEST(nowTest);
|
||||
CPPUNIT_TEST(sleepTest);
|
||||
CPPUNIT_TEST_SUITE_END();
|
||||
|
@ -88,6 +89,14 @@ class TimeConversionTest : public CPPUNIT_NS::TestFixture
|
|||
void
|
||||
tmToPtimeTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test conversion from ptime to struct tm
|
||||
*
|
||||
* @exception CPPUNIT_NS::Exception on test failures.
|
||||
*/
|
||||
void
|
||||
ptimeToTmTest(void) throw (CPPUNIT_NS::Exception);
|
||||
|
||||
/**
|
||||
* Test the now function.
|
||||
*
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue