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
59 return exactlyEqual (t1.inSeconds(), t2.inSeconds());
62JUCE_API
bool JUCE_CALLTYPE operator!= (RelativeTime t1, RelativeTime t2)
noexcept
67JUCE_API
bool JUCE_CALLTYPE operator> (RelativeTime t1, RelativeTime t2)
noexcept {
return t1.inSeconds() > t2.inSeconds(); }
68JUCE_API
bool JUCE_CALLTYPE operator< (RelativeTime t1, RelativeTime t2)
noexcept {
return t1.inSeconds() < t2.inSeconds(); }
69JUCE_API
bool JUCE_CALLTYPE operator>= (RelativeTime t1, RelativeTime t2)
noexcept {
return t1.inSeconds() >= t2.inSeconds(); }
70JUCE_API
bool JUCE_CALLTYPE operator<= (RelativeTime t1, RelativeTime t2)
noexcept {
return t1.inSeconds() <= t2.inSeconds(); }
73static String translateTimeField (
int n,
const char* singular,
const char* plural)
75 return TRANS (n == 1 ? singular : plural).replace (n == 1 ?
"1" :
"2", String (n));
78static String describeYears (
int n) {
return translateTimeField (n, NEEDS_TRANS (
"1 year"), NEEDS_TRANS (
"2 years")); }
79static String describeMonths (
int n) {
return translateTimeField (n, NEEDS_TRANS (
"1 month"), NEEDS_TRANS (
"2 months")); }
80static String describeWeeks (
int n) {
return translateTimeField (n, NEEDS_TRANS (
"1 week"), NEEDS_TRANS (
"2 weeks")); }
81static String describeDays (
int n) {
return translateTimeField (n, NEEDS_TRANS (
"1 day"), NEEDS_TRANS (
"2 days")); }
82static String describeHours (
int n) {
return translateTimeField (n, NEEDS_TRANS (
"1 hr"), NEEDS_TRANS (
"2 hrs")); }
83static String describeMinutes (
int n) {
return translateTimeField (n, NEEDS_TRANS (
"1 min"), NEEDS_TRANS (
"2 mins")); }
84static String describeSeconds (
int n) {
return translateTimeField (n, NEEDS_TRANS (
"1 sec"), NEEDS_TRANS (
"2 secs")); }
88 if (numSeconds <= 1.0)
93 if (
weeks > 52)
return describeYears (
weeks / 52);
94 if (
weeks > 8)
return describeMonths ((
weeks * 12) / 52);
100 return describeDays (
days);
105 return describeHours (
hours);
110 return describeMinutes (
minutes);
112 return describeSeconds ((
int) numSeconds);
117 if (std::abs (numSeconds) < 0.001)
118 return returnValueForZeroTime;
121 return "-" +
RelativeTime (-numSeconds).getDescription();
128 fields.
add (describeWeeks (n));
133 fields.
add (describeDays (n));
135 if (fields.
size() < 2)
140 fields.
add (describeHours (n));
142 if (fields.
size() < 2)
147 fields.
add (describeMinutes (n));
149 if (fields.
size() < 2)
154 fields.
add (describeSeconds (n));
int64 inMilliseconds() const noexcept
static RelativeTime minutes(double numberOfMinutes) noexcept
double inWeeks() const noexcept
String getDescription(const String &returnValueForZeroTime="0") const
double inDays() const noexcept
double inHours() const noexcept
static RelativeTime milliseconds(int milliseconds) noexcept
double inSeconds() const noexcept
static RelativeTime hours(double numberOfHours) noexcept
static RelativeTime days(double numberOfDays) noexcept
RelativeTime & operator=(const RelativeTime &other) noexcept
RelativeTime operator+=(RelativeTime timeToAdd) noexcept
RelativeTime operator-=(RelativeTime timeToSubtract) noexcept
String getApproximateDescription() const
static RelativeTime weeks(double numberOfWeeks) noexcept
static RelativeTime seconds(double seconds) noexcept
RelativeTime(double seconds=0.0) noexcept
double inMinutes() const noexcept
String joinIntoString(StringRef separatorString, int startIndex=0, int numberOfElements=-1) const
int size() const noexcept
void add(String stringToAdd)
bool isEmpty() const noexcept