Loading...
Searching...
No Matches
juce::RelativeTime Class Reference

## Detailed Description

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.

The documentation for this class was generated from the following file:

- juce_core/time/juce_RelativeTime.h

## Public Member Functions

| RelativeTime (double seconds=0.0) noexcept
| Creates a RelativeTime.
| 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.
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.

## Constructors and Destructors

## RelativeTime() [1/2]

juce::RelativeTime::RelativeTime | ( | double | seconds = 0.0 | ) |

explicit noexcept

Creates a RelativeTime.

Parameters

  seconds | the number of seconds, which may be +ve or -ve.

See also
  milliseconds, minutes, hours, days, weeks

References seconds().

Referenced by days(), hours(), milliseconds(), milliseconds(), minutes(), operator+=(), operator+=(), operator-=(), operator-=(), operator=(), RelativeTime(), seconds(), weeks(), and ~RelativeTime().

## RelativeTime() [2/2]

juce::RelativeTime::RelativeTime | ( | const RelativeTime & | other | ) |

noexcept

Copies another relative time.

References RelativeTime().

## ~RelativeTime()

juce::RelativeTime::~RelativeTime | ( |  | ) |

noexcept

Destructor.

References RelativeTime().

## Member Functions

## operator=()

RelativeTime & juce::RelativeTime::operator= | ( | const RelativeTime & | other | ) |

noexcept

Copies another relative time.

References RelativeTime().

## milliseconds() [1/2]

RelativeTime juce::RelativeTime::milliseconds | ( | int | milliseconds | ) |

static noexcept

Creates a new RelativeTime object representing a number of milliseconds.

See also
  seconds, minutes, hours, days, weeks

References milliseconds(), and RelativeTime().

Referenced by milliseconds(), and milliseconds().

## milliseconds() [2/2]

RelativeTime juce::RelativeTime::milliseconds | ( | int64 | milliseconds | ) |

static noexcept

Creates a new RelativeTime object representing a number of milliseconds.

See also
  seconds, minutes, hours, days, weeks

References milliseconds(), and RelativeTime().

## seconds()

RelativeTime juce::RelativeTime::seconds | ( | double | seconds | ) |

static noexcept

Creates a new RelativeTime object representing a number of seconds.

See also
  milliseconds, minutes, hours, days, weeks

References RelativeTime(), and seconds().

Referenced by juce::NetworkServiceDiscovery::Advertiser::Advertiser(), RelativeTime(), and seconds().

## minutes()

RelativeTime juce::RelativeTime::minutes | ( | double | numberOfMinutes | ) |

static noexcept

Creates a new RelativeTime object representing a number of minutes.

See also
  milliseconds, hours, days, weeks

References minutes(), and RelativeTime().

Referenced by minutes().

## hours()

RelativeTime juce::RelativeTime::hours | ( | double | numberOfHours | ) |

static noexcept

Creates a new RelativeTime object representing a number of hours.

See also
  milliseconds, minutes, days, weeks

References hours(), and RelativeTime().

Referenced by hours().

## days()

RelativeTime juce::RelativeTime::days | ( | double | numberOfDays | ) |

static noexcept

Creates a new RelativeTime object representing a number of days.

See also
  milliseconds, minutes, hours, weeks

References days(), and RelativeTime().

Referenced by days().

## weeks()

RelativeTime juce::RelativeTime::weeks | ( | double | numberOfWeeks | ) |

static noexcept

Creates a new RelativeTime object representing a number of weeks.

See also
  milliseconds, minutes, hours, days

References RelativeTime(), and weeks().

Referenced by weeks().

## inMilliseconds()

int64 juce::RelativeTime::inMilliseconds | ( |  | ) | const

noexcept

Returns the number of milliseconds this time represents.

See also
  milliseconds, inSeconds, inMinutes, inHours, inDays, inWeeks

References inMilliseconds().

Referenced by inMilliseconds().

## inSeconds()

double juce::RelativeTime::inSeconds | ( |  | ) | const

inline noexcept

Returns the number of seconds this time represents.

See also
  inMilliseconds, inMinutes, inHours, inDays, inWeeks

References inSeconds().

Referenced by inSeconds().

## inMinutes()

double juce::RelativeTime::inMinutes | ( |  | ) | const

noexcept

Returns the number of minutes this time represents.

See also
  inMilliseconds, inSeconds, inHours, inDays, inWeeks

## inHours()

double juce::RelativeTime::inHours | ( |  | ) | const

noexcept

Returns the number of hours this time represents.

See also
  inMilliseconds, inSeconds, inMinutes, inDays, inWeeks

References inHours().

Referenced by inHours().

## inDays()

double juce::RelativeTime::inDays | ( |  | ) | const

noexcept

Returns the number of days this time represents.

See also
  inMilliseconds, inSeconds, inMinutes, inHours, inWeeks

References inDays().

Referenced by inDays().

## inWeeks()

double juce::RelativeTime::inWeeks | ( |  | ) | const

noexcept

Returns the number of weeks this time represents.

See also
  inMilliseconds, inSeconds, inMinutes, inHours, inDays

References inWeeks().

Referenced by inWeeks().

## getDescription()

String juce::RelativeTime::getDescription | ( | const String & | returnValueForZeroTime = "0" | ) | const

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.

See also
  inMilliseconds, inSeconds, inMinutes, inHours, inDays, inWeeks

References getDescription().

Referenced by getDescription().

## getApproximateDescription()

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.

References getApproximateDescription().

Referenced by getApproximateDescription().

## operator+=() [1/2]

RelativeTime juce::RelativeTime::operator+= | ( | RelativeTime | timeToAdd | ) |

noexcept

Adds another RelativeTime to this one.

References RelativeTime().

## operator-=() [1/2]

RelativeTime juce::RelativeTime::operator-= | ( | RelativeTime | timeToSubtract | ) |

noexcept

Subtracts another RelativeTime from this one.

References RelativeTime().

## operator+=() [2/2]

RelativeTime juce::RelativeTime::operator+= | ( | double | secondsToAdd | ) |

noexcept

Adds a number of seconds to this time.

References RelativeTime().

## operator-=() [2/2]

RelativeTime juce::RelativeTime::operator-= | ( | double | secondsToSubtract | ) |

noexcept

Subtracts a number of seconds from this time.

References RelativeTime().

### Purchase

Get JUCE

### Discover

What's New in JUCE Features

### Learn

Documentaion Tutorials Made with JUCE Resources

### Support

JUCE Forum Newsletter Archive

### About

Contact Us JUCE Legal JUCE Licensing FAQ

### Events

Audio Developer Conference
© Raw Material Software Limited