OpenShot Audio Library | OpenShotAudio 0.3.2
Loading...
Searching...
No Matches
juce::RelativeTime Class Reference

#include <juce_RelativeTime.h>

Public Member Functions

 RelativeTime (double seconds=0.0) noexcept
 
 RelativeTime (const RelativeTime &other) noexcept
 
RelativeTimeoperator= (const RelativeTime &other) noexcept
 
 ~RelativeTime () noexcept
 
int64 inMilliseconds () const noexcept
 
double inSeconds () const noexcept
 
double inMinutes () const noexcept
 
double inHours () const noexcept
 
double inDays () const noexcept
 
double inWeeks () const noexcept
 
String getDescription (const String &returnValueForZeroTime="0") const
 
String getApproximateDescription () const
 
RelativeTime operator+= (RelativeTime timeToAdd) noexcept
 
RelativeTime operator-= (RelativeTime timeToSubtract) noexcept
 
RelativeTime operator+= (double secondsToAdd) noexcept
 
RelativeTime operator-= (double secondsToSubtract) noexcept
 

Static Public Member Functions

static RelativeTime milliseconds (int milliseconds) noexcept
 
static RelativeTime milliseconds (int64 milliseconds) noexcept
 
static RelativeTime seconds (double seconds) noexcept
 
static RelativeTime minutes (double numberOfMinutes) noexcept
 
static RelativeTime hours (double numberOfHours) noexcept
 
static RelativeTime days (double numberOfDays) noexcept
 
static RelativeTime weeks (double numberOfWeeks) noexcept
 

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.

Definition at line 36 of file juce_RelativeTime.h.

Constructor & Destructor Documentation

◆ RelativeTime() [1/2]

juce::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

Definition at line 26 of file juce_RelativeTime.cpp.

◆ RelativeTime() [2/2]

juce::RelativeTime::RelativeTime ( const RelativeTime other)
noexcept

Copies another relative time.

Definition at line 27 of file juce_RelativeTime.cpp.

◆ ~RelativeTime()

juce::RelativeTime::~RelativeTime ( )
noexcept

Destructor.

Definition at line 28 of file juce_RelativeTime.cpp.

Member Function Documentation

◆ days()

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

Creates a new RelativeTime object representing a number of days.

See also
milliseconds, minutes, hours, weeks

Definition at line 36 of file juce_RelativeTime.cpp.

Referenced by getApproximateDescription().

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

Definition at line 78 of file juce_RelativeTime.cpp.

◆ 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

Definition at line 107 of file juce_RelativeTime.cpp.

Referenced by getDescription().

◆ hours()

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

Creates a new RelativeTime object representing a number of hours.

See also
milliseconds, minutes, days, weeks

Definition at line 35 of file juce_RelativeTime.cpp.

Referenced by getApproximateDescription().

◆ inDays()

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

Returns the number of days this time represents.

See also
inMilliseconds, inSeconds, inMinutes, inHours, inWeeks

Definition at line 43 of file juce_RelativeTime.cpp.

Referenced by getDescription().

◆ inHours()

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

Returns the number of hours this time represents.

See also
inMilliseconds, inSeconds, inMinutes, inDays, inWeeks

Definition at line 42 of file juce_RelativeTime.cpp.

Referenced by getApproximateDescription(), and getDescription().

◆ inMilliseconds()

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

Returns the number of milliseconds this time represents.

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

Definition at line 40 of file juce_RelativeTime.cpp.

Referenced by getDescription().

◆ inMinutes()

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

Returns the number of minutes this time represents.

See also
inMilliseconds, inSeconds, inHours, inDays, inWeeks

Definition at line 41 of file juce_RelativeTime.cpp.

Referenced by getApproximateDescription(), and getDescription().

◆ inSeconds()

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

Returns the number of seconds this time represents.

See also
inMilliseconds, inMinutes, inHours, inDays, inWeeks

Definition at line 101 of file juce_RelativeTime.h.

Referenced by getDescription().

◆ inWeeks()

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

Returns the number of weeks this time represents.

See also
inMilliseconds, inSeconds, inMinutes, inHours, inDays

Definition at line 44 of file juce_RelativeTime.cpp.

Referenced by getApproximateDescription(), and getDescription().

◆ milliseconds() [1/2]

RelativeTime juce::RelativeTime::milliseconds ( int  milliseconds)
staticnoexcept

Creates a new RelativeTime object representing a number of milliseconds.

See also
seconds, minutes, hours, days, weeks

Definition at line 31 of file juce_RelativeTime.cpp.

Referenced by juce::TimeSliceThread::addTimeSliceClient(), and juce::TimeSliceThread::run().

◆ milliseconds() [2/2]

RelativeTime juce::RelativeTime::milliseconds ( int64  milliseconds)
staticnoexcept

Creates a new RelativeTime object representing a number of milliseconds.

See also
seconds, minutes, hours, days, weeks

Definition at line 32 of file juce_RelativeTime.cpp.

◆ minutes()

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

Creates a new RelativeTime object representing a number of minutes.

See also
milliseconds, hours, days, weeks

Definition at line 34 of file juce_RelativeTime.cpp.

Referenced by getApproximateDescription().

◆ operator+=() [1/2]

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

Adds a number of seconds to this time.

Definition at line 51 of file juce_RelativeTime.cpp.

◆ operator+=() [2/2]

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

Adds another RelativeTime to this one.

Definition at line 49 of file juce_RelativeTime.cpp.

◆ operator-=() [1/2]

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

Subtracts a number of seconds from this time.

Definition at line 52 of file juce_RelativeTime.cpp.

◆ operator-=() [2/2]

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

Subtracts another RelativeTime from this one.

Definition at line 50 of file juce_RelativeTime.cpp.

◆ operator=()

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

Copies another relative time.

Definition at line 47 of file juce_RelativeTime.cpp.

◆ seconds()

RelativeTime juce::RelativeTime::seconds ( double  seconds)
staticnoexcept

Creates a new RelativeTime object representing a number of seconds.

See also
milliseconds, minutes, hours, days, weeks

Definition at line 33 of file juce_RelativeTime.cpp.

◆ weeks()

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

Creates a new RelativeTime object representing a number of weeks.

See also
milliseconds, minutes, hours, days

Definition at line 37 of file juce_RelativeTime.cpp.

Referenced by getApproximateDescription().


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