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 1468 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 1473 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 1478 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 1520 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 1523 of file utils.h.
bool frepple::utils::TimePeriod::operator! |
( |
|
) |
const [inline] |
Returns true of the duration is equal to 0.
Definition at line 1517 of file utils.h.
bool frepple::utils::TimePeriod::operator!= |
( |
const TimePeriod & |
b |
) |
const [inline] |
Inequality operator.
Definition at line 1508 of file utils.h.
void frepple::utils::TimePeriod::operator+= |
( |
const TimePeriod & |
l |
) |
[inline] |
Increase the timeperiod.
Definition at line 1511 of file utils.h.
void frepple::utils::TimePeriod::operator-= |
( |
const TimePeriod & |
l |
) |
[inline] |
Decrease the timeperiod.
Definition at line 1514 of file utils.h.
bool frepple::utils::TimePeriod::operator< |
( |
const long & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1481 of file utils.h.
bool frepple::utils::TimePeriod::operator< |
( |
const TimePeriod & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1493 of file utils.h.
bool frepple::utils::TimePeriod::operator<= |
( |
const long & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1487 of file utils.h.
bool frepple::utils::TimePeriod::operator<= |
( |
const TimePeriod & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1499 of file utils.h.
bool frepple::utils::TimePeriod::operator== |
( |
const TimePeriod & |
b |
) |
const [inline] |
Equality operator.
Definition at line 1505 of file utils.h.
bool frepple::utils::TimePeriod::operator> |
( |
const long & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1484 of file utils.h.
bool frepple::utils::TimePeriod::operator> |
( |
const TimePeriod & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1496 of file utils.h.
bool frepple::utils::TimePeriod::operator>= |
( |
const TimePeriod & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1502 of file utils.h.
bool frepple::utils::TimePeriod::operator>= |
( |
const long & |
b |
) |
const [inline] |
Comparison between periods of time.
Definition at line 1490 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 143 of file date.cpp.
Friends And Related Function Documentation
ostream& operator<< |
( |
ostream & |
os, |
|
|
const TimePeriod & |
t | |
|
) |
| | [friend] |
Prints a Timeperiod to the outputstream.
- See also:
- TimePeriod::string()
Definition at line 1574 of file utils.h.
Member Data Documentation
The maximum value for a timeperiod.
Definition at line 1550 of file utils.h.
The minimum value for a timeperiod.
Definition at line 1553 of file utils.h.
The documentation for this class was generated from the following files: