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> 70 typedef boost::gregorian::date
Date;
73 using boost::date_time::Jan;
74 using boost::date_time::Feb;
75 using boost::date_time::Mar;
76 using boost::date_time::Apr;
77 using boost::date_time::May;
78 using boost::date_time::Jun;
79 using boost::date_time::Jul;
80 using boost::date_time::Aug;
81 using boost::date_time::Sep;
82 using boost::date_time::Oct;
83 using boost::date_time::Nov;
84 using boost::date_time::Dec;
86 using boost::date_time::Monday;
87 using boost::date_time::Tuesday;
88 using boost::date_time::Wednesday;
89 using boost::date_time::Thursday;
90 using boost::date_time::Friday;
91 using boost::date_time::Saturday;
92 using boost::date_time::Sunday;
106 class Duration :
public boost::posix_time::time_duration
110 typedef boost::posix_time::time_duration
Base;
121 #if defined(BOOST_DATE_TIME_HAS_NANOSECONDS) 136 #if defined(BOOST_DATE_TIME_HAS_NANOSECONDS) 151 #if defined(BOOST_DATE_TIME_HAS_NANOSECONDS) 152 d.ticks_ = v * 1000000;
189 Duration(hour_type hour, min_type min, sec_type sec,
190 fractional_seconds_type fs=0) :
191 Base(hour, min, sec, fs)
200 Duration(
const boost::posix_time::special_values sv) :
204 #if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR) 208 #endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR 215 template<
typename Reflector>
222 template<
typename Reflector>
237 return Duration(boost::posix_time::neg_infin);
244 return Duration(boost::posix_time::pos_infin);
251 return Duration(boost::posix_time::not_a_date_time);
259 return !this->is_not_a_date_time();
266 return this->is_pos_infinity() || this->is_neg_infinity();
272 return Base::hours();
277 return Base::minutes();
282 return Base::seconds();
302 return Base::total_seconds();
307 return Base::total_milliseconds();
312 return Base::total_microseconds();
317 return Base::total_nanoseconds();
326 return Base::operator -();
330 return Base::operator-(d);
334 return Base::operator+(d);
338 assert(divisor != 0);
339 return Base::operator/(divisor);
343 assert(divisor != 0.0f);
345 d.ticks_ = (int64)(ticks_.as_number() / divisor);
354 return Base::operator-=(d);
358 return Base::operator+=(d);
363 assert(divisor != 0);
364 return Base::operator/=(divisor);
368 assert(divisor != 0.0f);
369 ticks_ = (int64)(ticks_.as_number() / divisor);
375 return Base::operator*(rhs);
380 d.ticks_ = (int64)(ticks_.as_number() * rhs);
385 return Base::operator*=(rhs);
389 ticks_ = (int64)(ticks_.as_number() * rhs);
403 if ( duration.is_negative() )
404 return duration.invert_sign();
422 typedef boost::posix_time::ptime
Base;
441 Time(
const Base::time_rep_type& rhs) :
445 Time(
const boost::posix_time::special_values sv) :
449 #if !defined(DATE_TIME_NO_DEFAULT_CONSTRUCTOR) 453 #endif // DATE_TIME_NO_DEFAULT_CONSTRUCTOR 459 template<
typename Reflector>
462 int64 t = toUnixNS();
466 template<
typename Reflector>
484 return boost::posix_time::microsec_clock::universal_time();
494 static Time eternity()
496 return Time(boost::posix_time::max_date_time);
504 return Time(boost::posix_time::not_a_date_time);
559 typedef boost::date_time::c_local_adjustor<Base> l;
560 return l::utc_to_local(*
this);
571 boost::local_time::time_zone_ptr tz(
new boost::local_time::posix_time_zone(zone));
572 boost::local_time::local_date_time dt(*
this, tz);
573 return dt.local_time();
582 return !this->is_not_a_date_time();
591 return Base::operator-(t);
595 return Base::operator+(d);
599 return Base::operator+=(d);
603 return Base::operator-(d);
607 return Base::operator-=(d);
611 return Base::operator+(d);
615 return Base::operator+=(d);
619 return Base::operator-(d);
623 return Base::operator-=(d);
630 template<
typename SerializerTag>
633 template<
typename SerializerTag>
648 template<
typename Reflector>
654 template<
typename Reflector>
661 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:249
Duration operator/(float divisor) const
Definition: Time.h:341
Time(const boost::posix_time::special_values sv)
Construct from special value.
Definition: Time.h:445
Typedefs for OS independent basic data types.
Duration operator*=(float rhs)
Definition: Time.h:387
Type trait that indicates whether a type should be serialized "transparently", i.e.
Definition: IsTransparentSerializable.h:81
Duration operator*=(int rhs)
Definition: Time.h:383
static Duration microseconds(int64 v)
Can be used to construct a Duration object that is specified in microseconds.
Definition: Time.h:134
tick_type milliseconds() const
Returns normalized number of milliseconds (0..999)
Definition: Time.h:285
Duration(const Base &d)
Construct from base class.
Definition: Time.h:195
#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:436
static Duration minutes(int32 v)
Can be used to construct a Duration object that is specified in minutes.
Definition: Time.h:179
static Duration nanoseconds(int64 v)
Can be used to construct a Duration object that is specified in nanoseconds.
Definition: Time.h:119
static Time fromUnixNS(uint64 nanoseconds)
Creates a time representation out of a unix timestamp.
Definition: Time.h:548
Time toLocal() const
Converts to local time zone based on the settings of the machine.
Definition: Time.h:557
bool isValid() const
Checks if this duration is invalid.
Definition: Time.h:257
Time operator+=(const DateDuration &d)
Definition: Time.h:597
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:206
Time(const Base &p)
Construct from base class.
Definition: Time.h:432
bool isValid() const
Returns true if this contains a valid time.
Definition: Time.h:580
Duration operator+(const Duration &d) const
Definition: Time.h:332
Time operator-=(const Duration &d)
Definition: Time.h:621
#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:336
Duration operator/=(int divisor)
Division operations on a duration with an integer.
Definition: Time.h:361
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:511
tick_type totalNanoseconds() const
Returns total number of nanoseconds truncating any fractional nanoseconds.
Definition: Time.h:315
Duration(const boost::posix_time::special_values sv)
Construct from special value.
Definition: Time.h:200
boost::posix_time::ptime Base
Definition: Time.h:422
Wrapper class for boost::posix_time::ptime for adding more functionality to it.
Definition: Time.h:418
static Duration hours(int32 v)
Can be used to construct a Duration object that is specified in hours.
Definition: Time.h:186
Duration abs(const Duration &duration)
Get the absolute duration from a duration.
Definition: Time.h:401
Duration operator*(int rhs) const
Multiplication operations an a duration with an integer.
Definition: Time.h:373
boost::posix_time::time_duration Base
Definition: Time.h:110
static Duration seconds(int32 v)
Can be used to construct a Duration object that is specified in seconds.
Definition: Time.h:172
tick_type totalMilliseconds() const
Returns total number of milliseconds truncating any fractional milliseconds.
Definition: Time.h:305
float operator/(Duration other) const
Definition: Time.h:348
Duration operator-=(const Duration &d)
Definition: Time.h:352
By default, IsCheapToCopy<T>::value evaluates to true for fundamental types T, false for all other ty...
Definition: IsCheapToCopy.h:63
min_type minutes() const
Returns normalized number of minutes (0..59)
Definition: Time.h:275
sec_type seconds() const
Returns normalized number of seconds (0..59)
Definition: Time.h:280
Use this class to represent time durations.
Definition: Time.h:106
tick_type totalMicroseconds() const
Returns total number of microseconds truncating any fractional microseconds.
Definition: Time.h:310
boost::gregorian::date_duration DateDuration
Definition: Time.h:71
Time(Date d, Duration td)
Construct from date and timespan.
Definition: Time.h:427
boost::gregorian::date Date
Typedef for the boost Gregorian calendar date.
Definition: Time.h:70
Time operator-(const DateDuration &d) const
Definition: Time.h:601
Type trait to define if a class is cheap to copy.
hour_type hours() const
Returns number of hours in the duration.
Definition: Time.h:270
Duration operator-(const Time &t) const
Definition: Time.h:589
tick_type microseconds() const
Returns normalized number of microseconds (0..999)
Definition: Time.h:290
Time operator+(const DateDuration &d) const
Definition: Time.h:593
MIRA_SPLIT_REFLECT_MEMBER void reflectRead(Reflector &r)
Definition: Time.h:460
static Duration infinity()
Returns a special duration time representing positive infinity.
Definition: Time.h:242
static Duration negativeInfinity()
Returns a special duration time representing negative infinity.
Definition: Time.h:235
Duration operator+=(const Duration &d)
Definition: Time.h:356
Time toTimeZone(const std::string &zone)
Converts to given time zone.
Definition: Time.h:569
Duration(hour_type hour, min_type min, sec_type sec, fractional_seconds_type fs=0)
Definition: Time.h:189
Time(const Base::time_rep_type &rhs)
Construct from time representation.
Definition: Time.h:441
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:264
sec_type totalSeconds() const
Returns total number of seconds truncating any fractional seconds.
Definition: Time.h:300
static Time now() static Time eternity()
Returns the current utc based time.
Definition: Time.h:481
Time operator-(const Duration &d) const
Definition: Time.h:617
static Time invalid()
Returns an invalid time.
Definition: Time.h:502
Time operator+(const Duration &d) const
Definition: Time.h:609
static Duration milliseconds(int64 v)
Can be used to construct a Duration object that is specified in milliseconds.
Definition: Time.h:149
tick_type nanoseconds() const
Returns normalized number of nanoseconds (0..999)
Definition: Time.h:295
Duration operator-(const Duration &d) const
Definition: Time.h:328
Time operator+=(const Duration &d)
Definition: Time.h:613
Duration operator/=(float divisor)
Definition: Time.h:366
void reflectWrite(Reflector &r)
Definition: Time.h:467
void reflectWrite(Reflector &r)
Definition: Time.h:223
static Time fromUnixTimestamp(uint32 seconds)
Creates a time representation out of a unix timestamp.
Definition: Time.h:530
Duration operator-() const
Definition: Time.h:324
uint64 toUnixNS() const
Converts the current time to a unix timestamp in nanoseconds.
Definition: Time.h:539
Time operator-=(const DateDuration &d)
Definition: Time.h:605
Duration operator*(float rhs) const
Definition: Time.h:377
MIRA_SPLIT_REFLECT_MEMBER void reflectRead(Reflector &r)
Reflect.
Definition: Time.h:216
uint32 toUnixTimestamp() const
Converts the current time to a unix timestamp in seconds.
Definition: Time.h:521