40 PT_API std::string dateTimeToString(
const DateTime& dt);
43 PT_API std::string dateTimeToString(
const DateTime& dt,
int* utcOffset);
46 PT_API DateTime dateTimeFromString(
const std::string& s);
49 PT_API DateTime dateTimeFromString(
const std::string& s,
int* utcOffset);
76 unsigned h = 0,
unsigned min = 0,
77 unsigned s = 0,
unsigned ms = 0)
79 , _time(h, min, s, ms)
85 : _date( dateTime.
date() )
86 , _time( dateTime.
time() )
96 unsigned hour = 0,
unsigned min = 0,
unsigned sec = 0,
unsigned msec = 0);
101 unsigned&
hour,
unsigned& min,
unsigned& sec,
unsigned&
msec)
const;
116 { _date = dt;
return *
this; }
131 { _time = t;
return *
this; }
171 {
return dateTimeToString(*
this); }
176 {
return dateTimeToString(*
this, utcOffset); }
181 {
return dateTimeFromString(s); }
186 {
return dateTimeFromString(s, utcOffset); }
194 Pt::int64_t overrun = totalMSecs % Time::MSecsPerDay;
196 if( (-overrun) > _time.
toMSecs() )
200 else if( overrun + _time.
toMSecs() > Time::MSecsPerDay)
205 _date +=
static_cast<int>(days);
216 Pt::int64_t overrun = totalMSecs % Time::MSecsPerDay;
218 if( overrun > _time.
toMSecs() )
222 else if(_time.
toMSecs() - overrun > Time::MSecsPerDay)
227 _date -=
static_cast<int>(days);
228 _time -=
Timespan( overrun * 1000 );
283 Pt::int64_t result = (dayDiff * Time::MSecsPerDay + milliSecDiff) * 1000;
364 _date = dateTime.
date();
365 _time = dateTime.
time();
371 unsigned h,
unsigned min,
unsigned s,
unsigned ms)
373 _date.
set(y, mon, d);
374 _time.
set(h, min, s, ms);
379 unsigned& h,
unsigned& min,
unsigned& s,
unsigned& ms)
const
381 _date.
get(y, mon, d);
382 _time.
get(h, min, s, ms);
387 unsigned hour,
unsigned minute,
unsigned second,
unsigned msec)
394 #endif // PT_DATETIME_H
static bool isValid(unsigned h, unsigned m, unsigned s, unsigned ms)
Returns true if values are a valid time.
Definition: Time.h:298
Core module.
Definition: pt-gfx-images.dox:14
Date expressed in year, month, and day.
Definition: Date.h:104
unsigned minute() const
Returns the minute-part.
Definition: Time.h:152
unsigned day() const
Returns the day-part of the date.
Definition: Date.h:487
unsigned msec() const
Returns the millisecond-part.
Definition: Time.h:166
static DateTime fromIsoString(const std::string &s)
Interprets a string as a date and time in ISO-format.
Definition: DateTime.h:180
unsigned month() const
Returns the month-part of the date.
Definition: Date.h:495
void get(unsigned &h, unsigned &m, unsigned &s, unsigned &ms) const
Get the time values.
Definition: Time.h:206
Time & time()
Gets the time.
Definition: DateTime.h:125
void set(unsigned h, unsigned m, unsigned s, unsigned ms=0)
Sets the time.
Definition: Time.h:192
int year() const
Returns the year-part of the date.
Definition: DateTime.h:145
unsigned month() const
Returns the month-part of the date.
Definition: DateTime.h:140
int year() const
Returns the year-part of the date.
Definition: Date.h:503
DateTime(int y, unsigned mon, unsigned d, unsigned h=0, unsigned min=0, unsigned s=0, unsigned ms=0)
Construct to date and time.
Definition: DateTime.h:75
unsigned second() const
Returns the second-part.
Definition: Time.h:159
unsigned minute() const
Returns the minute-part of the Time.
Definition: DateTime.h:155
std::string toIsoString(int *utcOffset) const
Returns the date and time in ISO-format.
Definition: DateTime.h:175
void get(int &year, unsigned &month, unsigned &day) const
Gets the year, month and day.
Definition: Date.h:472
const Time & time() const
Gets the time.
Definition: DateTime.h:120
unsigned msec() const
Returns the millisecond-part of the Time.
Definition: DateTime.h:165
unsigned hour() const
Returns the hour-part.
Definition: Time.h:145
bool operator==(const DateTime &a, const DateTime &b)
Returns true if equal.
Definition: DateTime.h:347
int_type int64_t
Signed 64-bit integer type.
Definition: Types.h:48
DateTime & setTime(const Time &t)
Sets the time.
Definition: DateTime.h:130
Time expressed in hours, minutes, seconds and milliseconds.
Definition: Time.h:98
DateTime(const DateTime &dateTime)
Copy Constructor.
Definition: DateTime.h:84
unsigned hour() const
Returns the hour-part of the Time.
Definition: DateTime.h:150
Timespan operator-(const DateTime &first, const DateTime &second)
Subtract two DateTimes.
Definition: DateTime.h:275
Pt::int64_t toMSecs() const
Returns the total number of milliseconds.
Definition: Timespan.h:307
void set(int year, unsigned month, unsigned day, unsigned hour=0, unsigned min=0, unsigned sec=0, unsigned msec=0)
Sets the date and time.
Definition: DateTime.h:370
unsigned second() const
Returns the second-part of the Time.
Definition: DateTime.h:160
DateTime & setDate(const Date &dt)
Sets the date.
Definition: DateTime.h:115
uint32_t toMSecs() const
Converts to milliseconds.
Definition: Time.h:173
unsigned julian() const
Returns the Date as a julian day.
Definition: Date.h:236
unsigned day() const
Returns the day-part of the date.
Definition: DateTime.h:135
Represents time spans in microsecond resolution.
Definition: Timespan.h:63
bool operator!=(const DateTime &a, const DateTime &b)
Returns true if not equal.
Definition: DateTime.h:356
Date & date()
Gets the date.
Definition: DateTime.h:110
static bool isValid(int y, int m, int d)
Returns true if values describe a valid date.
Definition: Date.h:553
DateTime & operator-=(const Timespan &ts)
Assignment by difference operator.
Definition: DateTime.h:212
DateTime operator-(const DateTime &dt, const Timespan &ts)
Subtract a timespan.
Definition: DateTime.h:292
std::string toIsoString() const
Returns the date and time in ISO-format.
Definition: DateTime.h:170
void set(int y, unsigned m, unsigned d)
Sets the date to a year, month and day.
Definition: Date.h:244
DateTime operator+(const DateTime &dt, const Timespan &ts)
Add a timespan.
Definition: DateTime.h:264
DateTime & operator=(const DateTime &dateTime)
Assignment operator.
Definition: DateTime.h:362
Represents arbitrary types during serialization.
Definition: SerializationInfo.h:59
const Date & date() const
Gets the date.
Definition: DateTime.h:105
DateTime()
Default Constructor.
Definition: DateTime.h:70
static bool isValid(int year, unsigned month, unsigned day, unsigned hour, unsigned minute, unsigned second, unsigned msec)
Returns true if values are a valid date and time.
Definition: DateTime.h:386
void get(int &year, unsigned &month, unsigned &day, unsigned &hour, unsigned &min, unsigned &sec, unsigned &msec) const
Gets the date and time.
Definition: DateTime.h:378
DateTime & operator+=(const Timespan &ts)
Assignment by sum operator.
Definition: DateTime.h:190
static DateTime fromIsoString(const std::string &s, int *utcOffset)
Interprets a string as a date and time in ISO-format.
Definition: DateTime.h:185
Combined Date and Time value.
Definition: DateTime.h:66