55JUCE_API RelativeTime JUCE_CALLTYPE operator- (RelativeTime t1, RelativeTime t2)
noexcept {
return t1 -= t2; }
57JUCE_API bool JUCE_CALLTYPE operator== (RelativeTime t1, RelativeTime t2)
noexcept {
return t1.inSeconds() == t2.inSeconds(); }
58JUCE_API bool JUCE_CALLTYPE operator!= (RelativeTime t1, RelativeTime t2)
noexcept {
return t1.inSeconds() != t2.inSeconds(); }
59JUCE_API bool JUCE_CALLTYPE operator> (RelativeTime t1, RelativeTime t2)
noexcept {
return t1.inSeconds() > t2.inSeconds(); }
60JUCE_API bool JUCE_CALLTYPE operator< (RelativeTime t1, RelativeTime t2)
noexcept {
return t1.inSeconds() < t2.inSeconds(); }
61JUCE_API bool JUCE_CALLTYPE operator>= (RelativeTime t1, RelativeTime t2)
noexcept {
return t1.inSeconds() >= t2.inSeconds(); }
62JUCE_API bool JUCE_CALLTYPE operator<= (RelativeTime t1, RelativeTime t2)
noexcept {
return t1.inSeconds() <= t2.inSeconds(); }
65static void translateTimeField (String& result,
int n,
const char* singular,
const char* plural)
67 result << TRANS (n == 1 ? singular : plural)
68 .replace (n == 1 ?
"1" :
"2", String (n))
74 if (numSeconds < 0.001 && numSeconds > -0.001)
75 return returnValueForZeroTime;
84 int n = std::abs ((
int)
inWeeks());
87 translateTimeField (result, n, NEEDS_TRANS(
"1 week"), NEEDS_TRANS(
"2 weeks"));
91 n = std::abs ((
int)
inDays()) % 7;
94 translateTimeField (result, n, NEEDS_TRANS(
"1 day"), NEEDS_TRANS(
"2 days"));
100 n = std::abs ((
int)
inHours()) % 24;
103 translateTimeField (result, n, NEEDS_TRANS(
"1 hr"), NEEDS_TRANS(
"2 hrs"));
112 translateTimeField (result, n, NEEDS_TRANS(
"1 min"), NEEDS_TRANS(
"2 mins"));
121 translateTimeField (result, n, NEEDS_TRANS(
"1 sec"), NEEDS_TRANS(
"2 secs"));
125 if (fieldsShown == 0)
129 result << n <<
' ' << TRANS (
"ms");
A relative measure of time.
int64 inMilliseconds() const noexcept
Returns the number of milliseconds this time represents.
static RelativeTime minutes(double numberOfMinutes) noexcept
Creates a new RelativeTime object representing a number of minutes.
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.
double inDays() const noexcept
Returns the number of days this time represents.
double inHours() const noexcept
Returns the number of hours this time represents.
static RelativeTime milliseconds(int milliseconds) noexcept
Creates a new RelativeTime object representing a number of milliseconds.
double inSeconds() const noexcept
Returns the number of seconds this time represents.
~RelativeTime() noexcept
Destructor.
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.
RelativeTime & operator=(const RelativeTime &other) noexcept
Copies another relative time.
RelativeTime operator+=(RelativeTime timeToAdd) noexcept
Adds another RelativeTime to this one.
RelativeTime operator-=(RelativeTime timeToSubtract) noexcept
Subtracts another RelativeTime from this one.
static RelativeTime weeks(double numberOfWeeks) noexcept
Creates a new RelativeTime object representing a number of weeks.
static RelativeTime seconds(double seconds) noexcept
Creates a new RelativeTime object representing a number of seconds.
RelativeTime(double seconds=0.0) noexcept
Creates a RelativeTime.
double inMinutes() const noexcept
Returns the number of minutes this time represents.
void preallocateBytes(size_t numBytesNeeded)
Increases the string's internally allocated storage.
String trimEnd() const
Returns a copy of this string with any whitespace characters removed from the end.
#define JUCE_API
This macro is added to all JUCE public class declarations.