|
|
| Time () |
| | Construct a Time set to zero.
|
| | Time (unsigned h, unsigned m, unsigned s=0, unsigned ms=0) |
| | Construct from time values.
|
|
Time & | operator= (const Time &other) |
| | Assignment operator.
|
|
unsigned | hour () const |
| | Returns the hour-part.
|
|
unsigned | minute () const |
| | Returns the minute-part.
|
|
unsigned | second () const |
| | Returns the second-part.
|
|
unsigned | msec () const |
| | Returns the millisecond-part.
|
|
uint32_t | toMSecs () const |
| | Converts to milliseconds.
|
|
void | setTotalMSecs (uint32_t msecs) |
| | Sets to total milliseconds.
|
| void | set (unsigned h, unsigned m, unsigned s, unsigned ms=0) |
| | Sets the time.
|
| void | get (unsigned &h, unsigned &m, unsigned &s, unsigned &ms) const |
| | Get the time values.
|
| Time | addSecs (int secs) const |
| | Adds seconds to the time.
|
|
int | secsUntil (const Time &t) const |
| | Determines seconds until another time.
|
| Time | addMSecs (Pt::int64_t ms) const |
| | Adds milliseconds to the time.
|
|
Pt::int64_t | msecsUntil (const Time &t) const |
| | Calculates the milliseconds until another time.
|
|
std::string | toIsoString () const |
| | Returns the time in ISO-format (hh:mm:ss.hhh).
|
|
Time & | operator+= (const Timespan &ts) |
| | Assignment by sum operator.
|
|
Time & | operator-= (const Timespan &ts) |
| | Assignment by difference operator.
|
|
(Note that these are not member symbols.)
|
|
void | operator>>= (const SerializationInfo &si, Time &time) |
| | Deserialize a Time.
|
|
void | operator<<= (SerializationInfo &si, const Time &time) |
| | Serialize a Time.
|
|
bool | operator== (const Time &a, const Time &b) |
| | Equal comparison operator.
|
|
bool | operator!= (const Time &a, const Time &b) |
| | Inequal comparison operator.
|
|
bool | operator< (const Time &a, const Time &b) |
| | Less-than comparison operator.
|
|
bool | operator<= (const Time &a, const Time &b) |
| | Less-than-or-equal comparison operator.
|
|
bool | operator> (const Time &a, const Time &b) |
| | Greater-than comparison operator.
|
|
bool | operator>= (const Time &a, const Time &b) |
| | Greater-than-or-equal comparison operator.
|
|
Time | operator+ (const Time &time, const Timespan &ts) |
| | Addition operator.
|
|
Time | operator- (const Time &time, const Timespan &ts) |
| | Substraction operator.
|
|
Timespan | operator- (const Time &a, const Time &b) |
| | Substraction operator.
|
A Pt::Time object contains a wall-clock time in hours, minutes, seconds amd milliseconds. It can be constructed either from the numeric time values or from a string in ISO format using fromIsoString(). The separate time values can be accessed with hour(), minute(), second() and msec(). Times can be compared and a Time is considered less, if it is earlier than another Time. Subtracting a time from another yields a Pt::Timespan as the result. Pt::Timespans can also be added or subtracted from a Time, yielding a new Time or modifying it, as shown in the following example:
#include <Pt/Date.h>
#include <iostream>
{
return midnight - now;
}
Date expressed in year, month, and day.
Definition Date.h:104
static Time fromIsoString(const std::string &s)
Convert from an ISO time string.
Definition Time.h:273
Represents time spans in microsecond resolution.
Definition Timespan.h:63
Pt::InvalidTime is thrown, if a time could not be constructed, for example if one of the time values is out of range. To avoid an exception, time values can be validated with isValid().