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 String translateTimeField (
int n,
const char* singular,
const char* plural)
67 return TRANS (n == 1 ? singular : plural).replace (n == 1 ?
"1" :
"2", String (n));
70static String describeYears (
int n) {
return translateTimeField (n, NEEDS_TRANS(
"1 year"), NEEDS_TRANS(
"2 years")); }
71static String describeMonths (
int n) {
return translateTimeField (n, NEEDS_TRANS(
"1 month"), NEEDS_TRANS(
"2 months")); }
72static String describeWeeks (
int n) {
return translateTimeField (n, NEEDS_TRANS(
"1 week"), NEEDS_TRANS(
"2 weeks")); }
73static String describeDays (
int n) {
return translateTimeField (n, NEEDS_TRANS(
"1 day"), NEEDS_TRANS(
"2 days")); }
74static String describeHours (
int n) {
return translateTimeField (n, NEEDS_TRANS(
"1 hr"), NEEDS_TRANS(
"2 hrs")); }
75static String describeMinutes (
int n) {
return translateTimeField (n, NEEDS_TRANS(
"1 min"), NEEDS_TRANS(
"2 mins")); }
76static String describeSeconds (
int n) {
return translateTimeField (n, NEEDS_TRANS(
"1 sec"), NEEDS_TRANS(
"2 secs")); }
80 if (numSeconds <= 1.0)
85 if (
weeks > 52)
return describeYears (
weeks / 52);
86 if (
weeks > 8)
return describeMonths ((
weeks * 12) / 52);
92 return describeDays (
days);
97 return describeHours (
hours);
102 return describeMinutes (
minutes);
104 return describeSeconds ((
int) numSeconds);
109 if (std::abs (numSeconds) < 0.001)
154 return fields.joinIntoString (
" ");
bool isEmpty() const noexcept
int size() const noexcept
void add(const ElementType &newElement)
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