A relative measure of time. More...
Public Member Functions | |
| RelativeTime () noexcept=default | |
| Creates a RelativeTime with a period of zero seconds. | |
| RelativeTime (double seconds) noexcept | |
| Creates a RelativeTime. | |
| template<typename Rep , typename Period > | |
| RelativeTime (std::chrono::duration< Rep, Period > duration) noexcept | |
| Creates a relative time from a std::chrono::duration. | |
| 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. | |
| template<typename TimeUnit > | |
| auto | to () const noexcept |
| Converts this RelativeTime to a numeric value in the requested time unit. | |
| template<typename DurationType > | |
| auto | toStdDuration () const noexcept |
| Converts this RelativeTime to a std::chrono::duration. | |
| String | getDescription (const String &returnValueForZeroTime="0") const |
| Returns a readable textual description of the time. | |
| String | getApproximateDescription () const |
| This returns a string that roughly describes how long ago this time was, which can be handy for showing ages of files, etc. | |
| RelativeTime | operator+= (RelativeTime timeToAdd) noexcept |
| Adds another RelativeTime to this one. | |
| RelativeTime | operator-= (RelativeTime timeToSubtract) noexcept |
| Subtracts another RelativeTime from this one. | |
| RelativeTime | operator+= (double secondsToAdd) noexcept |
| Adds a number of seconds to this time. | |
| RelativeTime | operator-= (double secondsToSubtract) noexcept |
| Subtracts a number of seconds from this time. | |
Static Public Member Functions | |
| static RelativeTime | milliseconds (int milliseconds) noexcept |
| Creates a new RelativeTime object representing a number of milliseconds. | |
| static RelativeTime | milliseconds (int64 milliseconds) noexcept |
| Creates a new RelativeTime object representing a number of milliseconds. | |
| static RelativeTime | seconds (double seconds) noexcept |
| Creates a new RelativeTime object representing a number of seconds. | |
| static RelativeTime | minutes (double numberOfMinutes) noexcept |
| Creates a new RelativeTime object representing a number of minutes. | |
| static RelativeTime | hours (double numberOfHours) noexcept |
| Creates a new RelativeTime object representing a number of hours. | |
| static RelativeTime | days (double numberOfDays) noexcept |
| Creates a new RelativeTime object representing a number of days. | |
| static 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.
|
defaultnoexcept |
Creates a RelativeTime with a period of zero seconds.
|
explicitnoexcept |
Creates a RelativeTime.
| seconds | the number of seconds, which may be +ve or -ve. |
|
inlineexplicitnoexcept |
Creates a relative time from a std::chrono::duration.
|
noexcept |
Copies another relative time.
|
noexcept |
Destructor.
|
noexcept |
Copies another relative time.
|
staticnoexcept |
|
staticnoexcept |
|
staticnoexcept |
Creates a new RelativeTime object representing a number of seconds.
|
staticnoexcept |
Creates a new RelativeTime object representing a number of minutes.
|
staticnoexcept |
Creates a new RelativeTime object representing a number of hours.
|
staticnoexcept |
Creates a new RelativeTime object representing a number of days.
|
staticnoexcept |
Creates a new RelativeTime object representing a number of weeks.
|
noexcept |
|
inlinenoexcept |
Returns the number of seconds this time represents.
|
noexcept |
Returns the number of minutes this time represents.
|
noexcept |
Returns the number of hours this time represents.
|
noexcept |
Returns the number of days this time represents.
|
noexcept |
Returns the number of weeks this time represents.
Converts this RelativeTime to a numeric value in the requested time unit.
|
inlinenoexcept |
Converts this RelativeTime to a std::chrono::duration.
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.
| String juce::RelativeTime::getApproximateDescription | ( | ) | const |
This returns a string that roughly describes how long ago this time was, which can be handy for showing ages of files, etc.
This will only attempt to be accurate to within the nearest order of magnitude so returns strings such as "5 years", "2 weeks", "< 1 minute", "< 1 sec" etc.
|
noexcept |
Adds another RelativeTime to this one.
|
noexcept |
Subtracts another RelativeTime from this one.
|
noexcept |
Adds a number of seconds to this time.
|
noexcept |
Subtracts a number of seconds from this time.