51 #include <boost/date_time/posix_time/posix_time.hpp> 52 #include <boost/date_time/local_time/local_time.hpp> 53 #include <boost/date_time/c_local_time_adjustor.hpp> 68 typedef boost::gregorian::date
Date;
71 using boost::date_time::Jan;
72 using boost::date_time::Feb;
73 using boost::date_time::Mar;
74 using boost::date_time::Apr;
75 using boost::date_time::May;
76 using boost::date_time::Jun;
77 using boost::date_time::Jul;
78 using boost::date_time::Aug;
79 using boost::date_time::Sep;
80 using boost::date_time::Oct;
81 using boost::date_time::Nov;
82 using boost::date_time::Dec;
84 using boost::date_time::Monday;
85 using boost::date_time::Tuesday;
86 using boost::date_time::Wednesday;
87 using boost::date_time::Thursday;
88 using boost::date_time::Friday;
89 using boost::date_time::Saturday;
90 using boost::date_time::Sunday;
104 class Duration :
public boost::posix_time::time_duration
108 typedef boost::posix_time::time_duration
Base;
119 #if defined(BOOST_DATE_TIME_HAS_NANOSECONDS) 134 #if defined(BOOST_DATE_TIME_HAS_NANOSECONDS) 149 #if defined(BOOST_DATE_TIME_HAS_NANOSECONDS) 150 d.ticks_ = v * 1000000;
187 Duration(hour_type hour, min_type min, sec_type sec,
188 fractional_seconds_type fs=0) :
189 Base(hour, min, sec, fs)
198 Duration(
const boost::posix_time::special_values sv) :
202 #if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR) 206 #endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR 213 template<
typename Reflector>
220 template<
typename Reflector>
235 return Duration(boost::posix_time::neg_infin);
242 return Duration(boost::posix_time::pos_infin);
249 return Duration(boost::posix_time::not_a_date_time);
257 return !this->is_not_a_date_time();
264 return this->is_pos_infinity() || this->is_neg_infinity();
270 return Base::hours();
275 return Base::minutes();
280 return Base::seconds();
300 return Base::total_seconds();
305 return Base::total_milliseconds();
310 return Base::total_microseconds();
315 return Base::total_nanoseconds();
324 return Base::operator -();
328 return Base::operator-(d);
332 return Base::operator+(d);
336 assert(divisor != 0);
337 return Base::operator/(divisor);
341 assert(divisor != 0.0f);
343 d.ticks_ = (int64)(ticks_.as_number() / divisor);
352 return Base::operator-=(d);
356 return Base::operator+=(d);
361 assert(divisor != 0);
362 return Base::operator/=(divisor);
366 assert(divisor != 0.0f);
367 ticks_ = (int64)(ticks_.as_number() / divisor);
373 return Base::operator*(rhs);
378 d.ticks_ = (int64)(ticks_.as_number() * rhs);
383 return Base::operator*=(rhs);
387 ticks_ = (int64)(ticks_.as_number() * rhs);
401 if ( duration.is_negative() )
402 return duration.invert_sign();
420 typedef boost::posix_time::ptime
Base;
439 Time(
const Base::time_rep_type& rhs) :
443 Time(
const boost::posix_time::special_values sv) :
447 #if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR) 451 #endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR 457 template<
typename Reflector>
460 int64 t = toUnixNS();
464 template<
typename Reflector>
482 return boost::posix_time::microsec_clock::universal_time();
492 static Time eternity()
494 return Time(boost::posix_time::max_date_time);
502 return Time(boost::posix_time::not_a_date_time);
557 typedef boost::date_time::c_local_adjustor<Base> l;
558 return l::utc_to_local(*
this);
569 boost::local_time::time_zone_ptr tz(
new boost::local_time::posix_time_zone(zone));
570 boost::local_time::local_date_time dt(*
this, tz);
571 return dt.local_time();
580 return !this->is_not_a_date_time();
589 return Base::operator-(t);
593 return Base::operator+(d);
597 return Base::operator+=(d);
601 return Base::operator-(d);
605 return Base::operator-=(d);
609 return Base::operator+(d);
613 return Base::operator+=(d);
617 return Base::operator-(d);
621 return Base::operator-=(d);
626 template<
typename SerializerTag>
629 template<
typename SerializerTag>
636 template<
typename Reflector>
642 template<
typename Reflector>
649 template<
typename SerializerTag>
void reflectWrite(Reflector &r, Buffer< T, Allocator > &c)
Specialization of the non-intrusive reflect for Buffer.
Definition: Buffer.h:581
static Duration invalid()
Returns an invalid duration.
Definition: Time.h:247
Duration operator/(float divisor) const
Definition: Time.h:339
Time(const boost::posix_time::special_values sv)
Construct from special value.
Definition: Time.h:443
Typedefs for OS independent basic data types.
Duration operator*=(float rhs)
Definition: Time.h:385
Type trait that indicates whether a type should be serialized "transparently", i.e.
Definition: IsTransparentSerializable.h:81
Duration operator*=(int rhs)
Definition: Time.h:381
static Duration microseconds(int64 v)
Can be used to construct a Duration object that is specified in microseconds.
Definition: Time.h:132
tick_type milliseconds() const
Returns normalized number of milliseconds (0..999)
Definition: Time.h:283
Duration(const Base &d)
Construct from base class.
Definition: Time.h:193
#define MIRA_SPLIT_REFLECT(Type)
Macro that inserts a reflect() method consisting of just a call to splitReflect() (splitting to refle...
Definition: SplitReflect.h:150
Time(Date d)
Construct a time at start of the given day (midnight)
Definition: Time.h:434
static Duration minutes(int32 v)
Can be used to construct a Duration object that is specified in minutes.
Definition: Time.h:177
static Duration nanoseconds(int64 v)
Can be used to construct a Duration object that is specified in nanoseconds.
Definition: Time.h:117
static Time fromUnixNS(uint64 nanoseconds)
Creates a time representation out of a unix timestamp.
Definition: Time.h:546
Time toLocal() const
Converts to local time zone based on the settings of the machine.
Definition: Time.h:555
bool isValid() const
Checks if this duration is invalid.
Definition: Time.h:255
Time operator+=(const DateDuration &d)
Definition: Time.h:595
specialize cv::DataType for our ImgPixel and inherit from cv::DataType<Vec>
Definition: IOService.h:67
Duration()
Default constructor constructs to Duration of 0 length.
Definition: Time.h:204
Time(const Base &p)
Construct from base class.
Definition: Time.h:430
bool isValid() const
Returns true if this contains a valid time.
Definition: Time.h:578
Duration operator+(const Duration &d) const
Definition: Time.h:330
Time operator-=(const Duration &d)
Definition: Time.h:619
#define MIRA_SPLIT_REFLECT_MEMBER
Macro that insert a class member reflect() method just splitting reflection into a reflectRead() and ...
Definition: SplitReflect.h:209
Duration operator/(int divisor) const
Definition: Time.h:334
Duration operator/=(int divisor)
Division operations on a duration with an integer.
Definition: Time.h:359
Provides type trait that indicates whether a type should be serialized "transparently".
Provides MIRA_SPLIT_REFLECT macros.
static Time unixEpoch()
Returns the unix epoch 1.1.1970 0:0:0.000.
Definition: Time.h:509
tick_type totalNanoseconds() const
Returns total number of nanoseconds truncating any fractional nanoseconds.
Definition: Time.h:313
Duration(const boost::posix_time::special_values sv)
Construct from special value.
Definition: Time.h:198
boost::posix_time::ptime Base
Definition: Time.h:420
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:416
static Duration hours(int32 v)
Can be used to construct a Duration object that is specified in hours.
Definition: Time.h:184
Duration abs(const Duration &duration)
Get the absolute duration from a duration.
Definition: Time.h:399
Duration operator*(int rhs) const
Multiplication operations an a duration with an integer.
Definition: Time.h:371
boost::posix_time::time_duration Base
Definition: Time.h:108
static Duration seconds(int32 v)
Can be used to construct a Duration object that is specified in seconds.
Definition: Time.h:170
tick_type totalMilliseconds() const
Returns total number of milliseconds truncating any fractional milliseconds.
Definition: Time.h:303
float operator/(Duration other) const
Definition: Time.h:346
Duration operator-=(const Duration &d)
Definition: Time.h:350
min_type minutes() const
Returns normalized number of minutes (0..59)
Definition: Time.h:273
sec_type seconds() const
Returns normalized number of seconds (0..59)
Definition: Time.h:278
Use this class to represent time durations.
Definition: Time.h:104
tick_type totalMicroseconds() const
Returns total number of microseconds truncating any fractional microseconds.
Definition: Time.h:308
boost::gregorian::date_duration DateDuration
Definition: Time.h:69
Time(Date d, Duration td)
Construct from date and timespan.
Definition: Time.h:425
boost::gregorian::date Date
Typedef for the boost Gregorian calendar date.
Definition: Time.h:68
Time operator-(const DateDuration &d) const
Definition: Time.h:599
hour_type hours() const
Returns number of hours in the duration.
Definition: Time.h:268
Duration operator-(const Time &t) const
Definition: Time.h:587
tick_type microseconds() const
Returns normalized number of microseconds (0..999)
Definition: Time.h:288
Time operator+(const DateDuration &d) const
Definition: Time.h:591
MIRA_SPLIT_REFLECT_MEMBER void reflectRead(Reflector &r)
Definition: Time.h:458
static Duration infinity()
Returns a special duration time representing positive infinity.
Definition: Time.h:240
static Duration negativeInfinity()
Returns a special duration time representing negative infinity.
Definition: Time.h:233
Duration operator+=(const Duration &d)
Definition: Time.h:354
Time toTimeZone(const std::string &zone)
Converts to given time zone.
Definition: Time.h:567
Duration(hour_type hour, min_type min, sec_type sec, fractional_seconds_type fs=0)
Definition: Time.h:187
Time(const Base::time_rep_type &rhs)
Construct from time representation.
Definition: Time.h:439
void reflectRead(Reflector &r, Buffer< T, Allocator > &c)
Specialization of the non-intrusive reflect for Buffer.
Definition: Buffer.h:565
bool isInfinity() const
Checks if this duration is infinity.
Definition: Time.h:262
sec_type totalSeconds() const
Returns total number of seconds truncating any fractional seconds.
Definition: Time.h:298
static Time now() static Time eternity()
Returns the current utc based time.
Definition: Time.h:479
Time operator-(const Duration &d) const
Definition: Time.h:615
static Time invalid()
Returns an invalid time.
Definition: Time.h:500
Time operator+(const Duration &d) const
Definition: Time.h:607
static Duration milliseconds(int64 v)
Can be used to construct a Duration object that is specified in milliseconds.
Definition: Time.h:147
tick_type nanoseconds() const
Returns normalized number of nanoseconds (0..999)
Definition: Time.h:293
Duration operator-(const Duration &d) const
Definition: Time.h:326
Time operator+=(const Duration &d)
Definition: Time.h:611
Duration operator/=(float divisor)
Definition: Time.h:364
void reflectWrite(Reflector &r)
Definition: Time.h:465
void reflectWrite(Reflector &r)
Definition: Time.h:221
static Time fromUnixTimestamp(uint32 seconds)
Creates a time representation out of a unix timestamp.
Definition: Time.h:528
Duration operator-() const
Definition: Time.h:322
uint64 toUnixNS() const
Converts the current time to a unix timestamp in nanoseconds.
Definition: Time.h:537
Time operator-=(const DateDuration &d)
Definition: Time.h:603
Duration operator*(float rhs) const
Definition: Time.h:375
MIRA_SPLIT_REFLECT_MEMBER void reflectRead(Reflector &r)
Reflect.
Definition: Time.h:214
uint32 toUnixTimestamp() const
Converts the current time to a unix timestamp in seconds.
Definition: Time.h:519