65 static 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");
static RelativeTime days(double numberOfDays) noexcept
Creates a new RelativeTime object representing a number of days.
#define JUCE_API
This macro is added to all JUCE public class declarations.
RelativeTime & operator=(const RelativeTime &other) noexcept
Copies another relative time.
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 inDays() const noexcept
Returns the number of days this time represents.
A relative measure of time.
double inWeeks() const noexcept
Returns the number of weeks this time represents.
int64 inMilliseconds() const noexcept
Returns the number of milliseconds this time represents.
static RelativeTime seconds(double seconds) noexcept
Creates a new RelativeTime object representing a number of seconds.
String trimEnd() const
Returns a copy of this string with any whitespace characters removed from the end.
static RelativeTime hours(double numberOfHours) noexcept
Creates a new RelativeTime object representing a number of hours.
static RelativeTime minutes(double numberOfMinutes) noexcept
Creates a new RelativeTime object representing a number of minutes.
RelativeTime operator+=(RelativeTime timeToAdd) noexcept
Adds another RelativeTime to this one.
static RelativeTime weeks(double numberOfWeeks) noexcept
Creates a new RelativeTime object representing a number of weeks.
RelativeTime(double seconds=0.0) noexcept
Creates a RelativeTime.
String getDescription(const String &returnValueForZeroTime="0") const
Returns a readable textual description of the time.
void preallocateBytes(size_t numBytesNeeded)
Increases the string's internally allocated storage.
double inSeconds() const noexcept
Returns the number of seconds this time represents.
~RelativeTime() noexcept
Destructor.
RelativeTime operator-=(RelativeTime timeToSubtract) noexcept
Subtracts another RelativeTime from this one.
double inMinutes() const noexcept
Returns the number of minutes this time represents.