Elm  2
ELM is a library providing generic data structures, OS-independent interface, plugins and XML.
Time Class Reference

#include <elm/util/Time.h>

Public Member Functions

 Time ()
 
 Time (int t)
 
 Time (t::int64 t)
 
 Time (t::uint64 t)
 
 Time (const Time &t)
 
t::int64 time () const
 
t::int64 micros () const
 
t::int64 millis () const
 
t::int64 seconds () const
 
t::int64 mins () const
 
t::int64 hours () const
 
t::int64 days () const
 
t::int64 years () const
 
Time operator+ (const Time &t) const
 
Time operator- (const Time &t) const
 
Time operator* (int n) const
 
Time operator/ (const Time &t) const
 
bool operator== (const Time &t) const
 
bool operator!= (const Time &t) const
 
bool operator< (const Time &t) const
 
bool operator<= (const Time &t) const
 
bool operator> (const Time &t) const
 
bool operator>= (const Time &t) const
 

Static Public Attributes

const static t::int64 ONE_MS = 1000
 
const static t::int64 ONE_S = ONE_MS * 1000
 
const static t::int64 ONE_M = ONE_S * 60
 
const static t::int64 ONE_H = ONE_M * 60
 
const static t::int64 ONE_D = ONE_H * 24
 
const static t::int64 ONE_Y = ONE_D * 365
 

Detailed Description

Represents a time, a duration, a delay, etc. This class supports also negative time for time subtraction.

This class comes with usual comparison and computation operators. In addition, it provides several function to access the time with different units: microsecond, milliseconds, seconds, etc.

Constructor & Destructor Documentation

◆ Time() [1/5]

Time ( )
inline

Initialize a time to 0.

◆ Time() [2/5]

Time ( int  t)
inline

◆ Time() [3/5]

Time ( t::int64  t)
inline

Initialize a time with the given value.

◆ Time() [4/5]

Time ( t::uint64  t)
inline

◆ Time() [5/5]

Time ( const Time t)
inline

Copy a time.

Member Function Documentation

◆ days()

t::int64 days ( ) const
inline

Get the time in days.

Returns
Time in days.

References Time::ONE_D.

◆ hours()

t::int64 hours ( ) const
inline

Get the time in hours.

Returns
Time in hours.

References Time::ONE_H.

◆ micros()

t::int64 micros ( ) const
inline

Get the time in microseconds.

Returns
Time in microseconds.

◆ millis()

t::int64 millis ( ) const
inline

Get the time in milliseconds.

Returns
Time in milliseconds.

References Time::ONE_MS.

◆ mins()

t::int64 mins ( ) const
inline

Get the time in minutes.

Returns
Time in minutes.

References Time::ONE_M.

◆ operator!=()

bool operator!= ( const Time t) const
inline

◆ operator*()

Time operator* ( int  n) const
inline

◆ operator+()

Time operator+ ( const Time t) const
inline

◆ operator-()

Time operator- ( const Time t) const
inline

◆ operator/()

Time operator/ ( const Time t) const
inline

◆ operator<()

bool operator< ( const Time t) const
inline

◆ operator<=()

bool operator<= ( const Time t) const
inline

◆ operator==()

bool operator== ( const Time t) const
inline

◆ operator>()

bool operator> ( const Time t) const
inline

◆ operator>=()

bool operator>= ( const Time t) const
inline

◆ seconds()

t::int64 seconds ( ) const
inline

Get the time in seconds.

Returns
Time in seconds.

References Time::ONE_S.

◆ time()

t::int64 time ( ) const
inline

Get the time raw value, currently in milliseconds.

Returns
Time in milliseconds.

Referenced by elm::operator<<().

◆ years()

t::int64 years ( ) const
inline

Get the time in years.

Returns
Time in years.

References Time::ONE_Y.

Member Data Documentation

◆ ONE_D

const static t::int64 ONE_D = ONE_H * 24
static

Referenced by Time::days(), and elm::operator<<().

◆ ONE_H

const static t::int64 ONE_H = ONE_M * 60
static

Referenced by Time::hours(), and elm::operator<<().

◆ ONE_M

const static t::int64 ONE_M = ONE_S * 60
static

Referenced by Time::mins(), and elm::operator<<().

◆ ONE_MS

const static t::int64 ONE_MS = 1000
static

Referenced by Time::millis(), and elm::operator<<().

◆ ONE_S

const static t::int64 ONE_S = ONE_MS * 1000
static

Referenced by elm::operator<<(), and Time::seconds().

◆ ONE_Y

const static t::int64 ONE_Y = ONE_D * 365
static

Referenced by elm::operator<<(), and Time::years().


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