diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-12 21:12:07 +0100 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2015-10-12 21:12:07 +0100 |
commit | 33c3ebf824daaa794cd65e0a2c956432c90629a4 (patch) | |
tree | d37eacf9bd49a6c64481d18622f5da500460e31c | |
parent | Implement date conversions and fix month/year offsets (diff) | |
download | slicer-33c3ebf824daaa794cd65e0a2c956432c90629a4.tar.bz2 slicer-33c3ebf824daaa794cd65e0a2c956432c90629a4.tar.xz slicer-33c3ebf824daaa794cd65e0a2c956432c90629a4.zip |
Add database specific type (timespan) and convertors
-rw-r--r-- | slicer/test/conversions.cpp | 12 | ||||
-rw-r--r-- | slicer/test/preprocessor.cpp | 2 | ||||
-rw-r--r-- | slicer/test/types.ice | 13 |
3 files changed, 26 insertions, 1 deletions
diff --git a/slicer/test/conversions.cpp b/slicer/test/conversions.cpp index fe0537c..1ea6239 100644 --- a/slicer/test/conversions.cpp +++ b/slicer/test/conversions.cpp @@ -77,5 +77,17 @@ namespace Slicer { SHORT(tm.tm_year + 1900), SHORT(tm.tm_mon + 1), SHORT(tm.tm_mday), SHORT(tm.tm_hour), SHORT(tm.tm_min), SHORT(tm.tm_sec)}); } + + ::DB::Timespan + timedurationToTimespan(const boost::posix_time::time_duration & td) + { + return ::DB::Timespan({ SHORT(td.hours() / 24), SHORT(td.hours() % 24), SHORT(td.minutes()), SHORT(td.seconds()) }); + } + + boost::posix_time::time_duration + timespanToTimeduration(const ::DB::Timespan & ts) + { + return boost::posix_time::time_duration((ts.days * 24) + ts.hours, ts.minutes, ts.seconds); + } } diff --git a/slicer/test/preprocessor.cpp b/slicer/test/preprocessor.cpp index 9c1218b..bef901e 100644 --- a/slicer/test/preprocessor.cpp +++ b/slicer/test/preprocessor.cpp @@ -13,7 +13,7 @@ namespace fs = boost::filesystem; -const unsigned int COMPONENTS_IN_TEST_ICE = 30; +const unsigned int COMPONENTS_IN_TEST_ICE = 32; BOOST_FIXTURE_TEST_SUITE ( preprocessor, FileStructure ); diff --git a/slicer/test/types.ice b/slicer/test/types.ice index 8f44fa0..73da2a0 100644 --- a/slicer/test/types.ice +++ b/slicer/test/types.ice @@ -134,3 +134,16 @@ module TestModule2 { }; }; +module DB { + [ "slicer:conversion:boost.posix_time.time_duration:timedurationToTimespan:timespanToTimeduration" ] + struct Timespan { + int days; + short hours; + short minutes; + short seconds; + }; + class SpecificTypes extends TestModule::DateTimeContainer { + Timespan ts; + }; +}; + |