frepple::utils::TimePeriod Class Reference
This class represents a time duration with an accuracy of one second.
More...
#include <utils.h>
List of all members.
Detailed Description
This class represents a time duration with an accuracy of one second.
The duration can be both positive and negative.
Definition at line 1443 of file utils.h.
Constructor & Destructor Documentation
frepple::utils::TimePeriod::TimePeriod |
( |
const long |
l = 0 |
) |
[inline] |
Default constructor and constructor with timeperiod passed.
Definition at line 1448 of file utils.h.
frepple::utils::TimePeriod::TimePeriod |
( |
const char * |
s |
) |
[inline] |
Constructor from a character string.
See the parse() method for details on the format of the argument.
Definition at line 1453 of file utils.h.
Member Function Documentation
frepple::utils::TimePeriod::operator long |
( |
|
) |
const [inline] |
This conversion operator creates a long value from a timeperiod.
Definition at line 1495 of file utils.h.
frepple::utils::TimePeriod::operator string |
( |
|
) |
const [inline] |
Converts the date to a string, formatted according to ISO 8601.
Definition at line 1498 of file utils.h.
bool frepple::utils::TimePeriod::operator! |
( |
|
) |
const [inline] |
Returns true of the duration is equal to 0.
Definition at line 1492 of file utils.h.
bool frepple::utils::TimePeriod::operator!= |
( |
const TimePeriod & |
b |
) |
const [inline] |
Inequality operator.
Definition at line 1483 of file utils.h.
void frepple::utils::TimePeriod::operator+= |
( |
const TimePeriod & |
l |
) |
[inline] |
Increase the timeperiod.
Definition at line 1486 of file utils.h.
void frepple::utils::TimePeriod::operator-= |
( |
const TimePeriod & |
l |
) |
[inline] |
Decrease the timeperiod.
Definition at line 1489 of file utils.h.
bool frepple::utils::TimePeriod::operator< |
( |
const TimePeriod & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1468 of file utils.h.
bool frepple::utils::TimePeriod::operator< |
( |
const long & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1456 of file utils.h.
bool frepple::utils::TimePeriod::operator<= |
( |
const TimePeriod & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1474 of file utils.h.
bool frepple::utils::TimePeriod::operator<= |
( |
const long & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1462 of file utils.h.
bool frepple::utils::TimePeriod::operator== |
( |
const TimePeriod & |
b |
) |
const [inline] |
Equality operator.
Definition at line 1480 of file utils.h.
bool frepple::utils::TimePeriod::operator> |
( |
const TimePeriod & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1471 of file utils.h.
bool frepple::utils::TimePeriod::operator> |
( |
const long & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1459 of file utils.h.
bool frepple::utils::TimePeriod::operator>= |
( |
const TimePeriod & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1477 of file utils.h.
bool frepple::utils::TimePeriod::operator>= |
( |
const long & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1465 of file utils.h.
void frepple::utils::TimePeriod::parse |
( |
const char * |
s |
) |
|
Function that parses a input string to a time value.
The string format is following the ISO 8601 specification for durations: [-]P[nY][nM][nW][nD][T[nH][nM][nS]]
Some examples to illustrate how the string is converted to a timeperiod, expressed in seconds:
P1Y = 1 year = 365 days = 31536000 seconds P1M = 365/12 days = 2628000 seconds P1W = 1 week = 7 days = 604800 seconds -P1D = -1 day = -86400 seconds PT1H = 1 hour = 3600 seconds -PT1000000S = 1000000 seconds P1M1WT1H = 1 month + 1 week + 1 hour = 3236400 seconds It pretty strictly checks the spec, with a few exceptions:
- A week field ('W') may coexist with other units.
- Decimal values are not supported.
- The alternate format as a date and time is not supported.
Definition at line 142 of file date.cpp.
Friends And Related Function Documentation
ostream& operator<< |
( |
ostream & |
, |
|
|
const TimePeriod & |
| |
|
) |
| | [friend] |
Member Data Documentation
The maximum value for a timeperiod.
Definition at line 1525 of file utils.h.
The minimum value for a timeperiod.
Definition at line 1528 of file utils.h.
The documentation for this class was generated from the following files: