JUCE
Public Member Functions | Static Public Member Functions | List of all members
RelativeTime Class Reference

A relative measure of time. More...

Public Member Functions

 RelativeTime (double seconds=0.0) noexcept
 Creates a RelativeTime. More...
 
 RelativeTime (const RelativeTime &other) noexcept
 Copies another relative time. More...
 
RelativeTimeoperator= (const RelativeTime &other) noexcept
 Copies another relative time. More...
 
 ~RelativeTime () noexcept
 Destructor. More...
 
int64 inMilliseconds () const noexcept
 Returns the number of milliseconds this time represents. More...
 
double inSeconds () const noexcept
 Returns the number of seconds this time represents. More...
 
double inMinutes () const noexcept
 Returns the number of minutes this time represents. More...
 
double inHours () const noexcept
 Returns the number of hours this time represents. More...
 
double inDays () const noexcept
 Returns the number of days this time represents. More...
 
double inWeeks () const noexcept
 Returns the number of weeks this time represents. More...
 
String getDescription (const String &returnValueForZeroTime="0") const
 Returns a readable textual description of the time. More...
 
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. More...
 
RelativeTime operator+= (RelativeTime timeToAdd) noexcept
 Adds another RelativeTime to this one. More...
 
RelativeTime operator-= (RelativeTime timeToSubtract) noexcept
 Subtracts another RelativeTime from this one. More...
 
RelativeTime operator+= (double secondsToAdd) noexcept
 Adds a number of seconds to this time. More...
 
RelativeTime operator-= (double secondsToSubtract) noexcept
 Subtracts a number of seconds from this time. More...
 

Static Public Member Functions

static RelativeTime milliseconds (int milliseconds) noexcept
 Creates a new RelativeTime object representing a number of milliseconds. More...
 
static RelativeTime milliseconds (int64 milliseconds) noexcept
 Creates a new RelativeTime object representing a number of milliseconds. More...
 
static RelativeTime seconds (double seconds) noexcept
 Creates a new RelativeTime object representing a number of seconds. More...
 
static RelativeTime minutes (double numberOfMinutes) noexcept
 Creates a new RelativeTime object representing a number of minutes. More...
 
static RelativeTime hours (double numberOfHours) noexcept
 Creates a new RelativeTime object representing a number of hours. More...
 
static RelativeTime days (double numberOfDays) noexcept
 Creates a new RelativeTime object representing a number of days. More...
 
static RelativeTime weeks (double numberOfWeeks) noexcept
 Creates a new RelativeTime object representing a number of weeks. More...
 

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.

Constructor & Destructor Documentation

◆ RelativeTime() [1/2]

RelativeTime::RelativeTime ( double  seconds = 0.0)
explicitnoexcept

Creates a RelativeTime.

Parameters
secondsthe number of seconds, which may be +ve or -ve.
See also
milliseconds, minutes, hours, days, weeks

◆ RelativeTime() [2/2]

RelativeTime::RelativeTime ( const RelativeTime other)
noexcept

Copies another relative time.

◆ ~RelativeTime()

RelativeTime::~RelativeTime ( )
noexcept

Destructor.

Member Function Documentation

◆ operator=()

RelativeTime& RelativeTime::operator= ( const RelativeTime other)
noexcept

Copies another relative time.

◆ milliseconds() [1/2]

static RelativeTime RelativeTime::milliseconds ( int  milliseconds)
staticnoexcept

Creates a new RelativeTime object representing a number of milliseconds.

See also
seconds, minutes, hours, days, weeks

Referenced by littlefoot::LittleFootRemoteHeap< ImplementationClass >::sendChanges().

◆ milliseconds() [2/2]

static RelativeTime RelativeTime::milliseconds ( int64  milliseconds)
staticnoexcept

Creates a new RelativeTime object representing a number of milliseconds.

See also
seconds, minutes, hours, days, weeks

◆ seconds()

static RelativeTime RelativeTime::seconds ( double  seconds)
staticnoexcept

Creates a new RelativeTime object representing a number of seconds.

See also
milliseconds, minutes, hours, days, weeks

◆ minutes()

static RelativeTime RelativeTime::minutes ( double  numberOfMinutes)
staticnoexcept

Creates a new RelativeTime object representing a number of minutes.

See also
milliseconds, hours, days, weeks

◆ hours()

static RelativeTime RelativeTime::hours ( double  numberOfHours)
staticnoexcept

Creates a new RelativeTime object representing a number of hours.

See also
milliseconds, minutes, days, weeks

◆ days()

static RelativeTime RelativeTime::days ( double  numberOfDays)
staticnoexcept

Creates a new RelativeTime object representing a number of days.

See also
milliseconds, minutes, hours, weeks

◆ weeks()

static RelativeTime RelativeTime::weeks ( double  numberOfWeeks)
staticnoexcept

Creates a new RelativeTime object representing a number of weeks.

See also
milliseconds, minutes, hours, days

◆ inMilliseconds()

int64 RelativeTime::inMilliseconds ( ) const
noexcept

Returns the number of milliseconds this time represents.

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

◆ inSeconds()

double RelativeTime::inSeconds ( ) const
noexcept

◆ inMinutes()

double RelativeTime::inMinutes ( ) const
noexcept

Returns the number of minutes this time represents.

See also
inMilliseconds, inSeconds, inHours, inDays, inWeeks

◆ inHours()

double RelativeTime::inHours ( ) const
noexcept

Returns the number of hours this time represents.

See also
inMilliseconds, inSeconds, inMinutes, inDays, inWeeks

◆ inDays()

double RelativeTime::inDays ( ) const
noexcept

Returns the number of days this time represents.

See also
inMilliseconds, inSeconds, inMinutes, inHours, inWeeks

◆ inWeeks()

double RelativeTime::inWeeks ( ) const
noexcept

Returns the number of weeks this time represents.

See also
inMilliseconds, inSeconds, inMinutes, inHours, inDays

◆ getDescription()

String 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

◆ getApproximateDescription()

String 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.

◆ operator+=() [1/2]

RelativeTime RelativeTime::operator+= ( RelativeTime  timeToAdd)
noexcept

Adds another RelativeTime to this one.

◆ operator-=() [1/2]

RelativeTime RelativeTime::operator-= ( RelativeTime  timeToSubtract)
noexcept

Subtracts another RelativeTime from this one.

◆ operator+=() [2/2]

RelativeTime RelativeTime::operator+= ( double  secondsToAdd)
noexcept

Adds a number of seconds to this time.

◆ operator-=() [2/2]

RelativeTime RelativeTime::operator-= ( double  secondsToSubtract)
noexcept

Subtracts a number of seconds from this time.


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