A relative measure of time. More...
Public Member Functions | |
| RelativeTime (double seconds=0.0) noexcept | |
| Creates a RelativeTime. | |
| RelativeTime (const RelativeTime &other) noexcept | |
| Copies another relative time. | |
| RelativeTime & | operator= (const RelativeTime &other) noexcept |
| Copies another relative time. | |
| ~RelativeTime () noexcept | |
| Destructor. | |
| int64 | inMilliseconds () const noexcept |
| Returns the number of milliseconds this time represents. | |
| double | inSeconds () const noexcept |
| Returns the number of seconds this time represents. | |
| double | inMinutes () const noexcept |
| Returns the number of minutes this time represents. | |
| double | inHours () const noexcept |
| Returns the number of hours this time represents. | |
| double | inDays () const noexcept |
| Returns the number of days this time represents. | |
| double | inWeeks () const noexcept |
| Returns the number of weeks this time represents. | |
| String | getDescription (const String &returnValueForZeroTime="0") const |
| Returns a readable textual description of the time. | |
| const RelativeTime & | operator+= (const RelativeTime &timeToAdd) noexcept |
| Adds another RelativeTime to this one. | |
| const RelativeTime & | operator-= (const RelativeTime &timeToSubtract) noexcept |
| Subtracts another RelativeTime from this one. | |
| const RelativeTime & | operator+= (double secondsToAdd) noexcept |
| Adds a number of seconds to this time. | |
| const RelativeTime & | operator-= (double secondsToSubtract) noexcept |
| Subtracts a number of seconds from this time. | |
Static Public Member Functions | |
| static const RelativeTime | milliseconds (int milliseconds) noexcept |
| Creates a new RelativeTime object representing a number of milliseconds. | |
| static const RelativeTime | milliseconds (int64 milliseconds) noexcept |
| Creates a new RelativeTime object representing a number of milliseconds. | |
| static const RelativeTime | minutes (double numberOfMinutes) noexcept |
| Creates a new RelativeTime object representing a number of minutes. | |
| static const RelativeTime | hours (double numberOfHours) noexcept |
| Creates a new RelativeTime object representing a number of hours. | |
| static const RelativeTime | days (double numberOfDays) noexcept |
| Creates a new RelativeTime object representing a number of days. | |
| static const RelativeTime | weeks (double numberOfWeeks) noexcept |
| Creates a new RelativeTime object representing a number of weeks. | |
A relative measure of time.
The time is stored as a number of seconds, at double-precision floating point accuracy, and may be positive or negative.
If you need an absolute time, (i.e. a date + time), see the Time class.
| RelativeTime::RelativeTime | ( | double | seconds = 0.0 | ) | [explicit] |
Creates a RelativeTime.
| seconds | the number of seconds, which may be +ve or -ve. |
| RelativeTime::RelativeTime | ( | const RelativeTime & | other | ) |
Copies another relative time.
Destructor.
| RelativeTime& RelativeTime::operator= | ( | const RelativeTime & | other | ) |
Copies another relative time.
| static const RelativeTime RelativeTime::milliseconds | ( | int | milliseconds | ) | [static] |
Creates a new RelativeTime object representing a number of milliseconds.
| static const RelativeTime RelativeTime::milliseconds | ( | int64 | milliseconds | ) | [static] |
Creates a new RelativeTime object representing a number of milliseconds.
| static const RelativeTime RelativeTime::minutes | ( | double | numberOfMinutes | ) | [static] |
Creates a new RelativeTime object representing a number of minutes.
| static const RelativeTime RelativeTime::hours | ( | double | numberOfHours | ) | [static] |
Creates a new RelativeTime object representing a number of hours.
| static const RelativeTime RelativeTime::days | ( | double | numberOfDays | ) | [static] |
Creates a new RelativeTime object representing a number of days.
| static const RelativeTime RelativeTime::weeks | ( | double | numberOfWeeks | ) | [static] |
Creates a new RelativeTime object representing a number of weeks.
| int64 RelativeTime::inMilliseconds | ( | ) | const |
| double RelativeTime::inSeconds | ( | ) | const |
Returns the number of seconds this time represents.
| double RelativeTime::inMinutes | ( | ) | const |
Returns the number of minutes this time represents.
| double RelativeTime::inHours | ( | ) | const |
Returns the number of hours this time represents.
| double RelativeTime::inDays | ( | ) | const |
Returns the number of days this time represents.
| double RelativeTime::inWeeks | ( | ) | const |
Returns the number of weeks this time represents.
| String RelativeTime::getDescription | ( | const String & | returnValueForZeroTime = "0" | ) | const |
Returns a readable textual description of the time.
The exact format of the string returned will depend on the magnitude of the time - e.g.
"1 min 4 secs", "1 hr 45 mins", "2 weeks 5 days", "140 ms"
so that only the two most significant units are printed.
The returnValueForZeroTime value is the result that is returned if the length is zero. Depending on your application you might want to use this to return something more relevant like "empty" or "0 secs", etc.
| const RelativeTime& RelativeTime::operator+= | ( | const RelativeTime & | timeToAdd | ) |
Adds another RelativeTime to this one.
| const RelativeTime& RelativeTime::operator-= | ( | const RelativeTime & | timeToSubtract | ) |
Subtracts another RelativeTime from this one.
| const RelativeTime& RelativeTime::operator+= | ( | double | secondsToAdd | ) |
Adds a number of seconds to this time.
| const RelativeTime& RelativeTime::operator-= | ( | double | secondsToSubtract | ) |
Subtracts a number of seconds from this time.