25 #ifndef STTCLBOOSTTIME_H_
26 #define STTCLBOOSTTIME_H_
28 #if defined(STTCL_BOOST_TIME) or defined(STTCL_BOOST_IMPL)
29 #include <boost/date_time/posix_time/posix_time.hpp>
30 using namespace boost;
31 using namespace boost::posix_time;
32 using namespace boost::date_time;
44 class SttclBoostTimeDuration
47 typedef boost::posix_time::time_duration NativeTimeDuration;
49 SttclBoostTimeDuration(
unsigned int argHours,
unsigned int argMinutes,
unsigned int argSeconds = 0,
unsigned int argMilliSeconds = 0,
unsigned long argMicroSeconds = 0,
unsigned long argNanoSeconds = 0)
50 : td(argHours,argMinutes,argSeconds,NativeTimeDuration::fractional_seconds_type(0))
52 td += boost::posix_time::milliseconds(argMilliSeconds);
53 td += boost::posix_time::microseconds(argMicroSeconds);
54 #ifdef BOOST_DATE_TIME_HAS_NANOSECONDS
55 td += boost::posix_time::nanoseconds(argNanoSeconds);
58 SttclBoostTimeDuration(
const SttclBoostTimeDuration& rhs)
62 SttclBoostTimeDuration(
const NativeTimeDuration& nativeTimeDuration)
63 : td(nativeTimeDuration)
66 ~SttclBoostTimeDuration()
70 SttclBoostTimeDuration& operator=(
const SttclBoostTimeDuration& rhs)
76 bool operator==(
const SttclBoostTimeDuration& rhs)
const
80 bool operator!=(
const SttclBoostTimeDuration& rhs)
const
84 bool operator<(
const SttclBoostTimeDuration& rhs)
const
88 bool operator<=(
const SttclBoostTimeDuration& rhs)
const
93 bool operator>(
const SttclBoostTimeDuration& rhs)
const
97 bool operator>=(
const SttclBoostTimeDuration& rhs)
const
102 SttclBoostTimeDuration& operator+=(
const SttclBoostTimeDuration& rhs)
108 SttclBoostTimeDuration& operator-=(
const SttclBoostTimeDuration& rhs)
114 SttclBoostTimeDuration& operator*=(
int factor)
120 SttclBoostTimeDuration& operator/=(
int divider)
141 long milliseconds()
const
143 return td.total_milliseconds();
145 long microseconds()
const
147 return td.total_microseconds();
149 long nanoseconds()
const
151 return td.total_nanoseconds();
154 void hours(
int newHours)
156 NativeTimeDuration result(td);
157 result -= NativeTimeDuration(td.hours() + newHours,0,0);
160 void minutes(
int newMinutes)
162 NativeTimeDuration result(td);
163 result -= NativeTimeDuration(0,td.minutes() + newMinutes,0);
166 void seconds(
int newSeconds)
168 NativeTimeDuration result(td);
169 result -= NativeTimeDuration(0,0,td.seconds() + newSeconds);
198 const NativeTimeDuration& getNativeValue()
const
204 NativeTimeDuration td;