#include <Iguana/Utilities/classlib/utils/Time.h>
Public Types | |
typedef TimeConst::TimeValue | ValueType |
Public Member Functions | |
long | days (void) const |
Get the number of complete days in the span. | |
long | hours (void) const |
Get the number of complete hours in the span. | |
long | lastHours (void) const |
Get the number of complete hours in the last incomplete day of the span. | |
long | lastMinutes (void) const |
Get the number of complete minutes in the last incomplete hour of the span. | |
long | lastNSeconds (void) const |
Get the number of nanoseconds in the last incomplete second of the span. | |
long | lastSeconds (void) const |
Get the number of complete seconds in the last incomplete minute of the span. | |
long | minutes (void) const |
Get the number of complete minutes in the span. | |
ValueType | ns (void) const |
Return the time span as nanoseconds. | |
TimeSpan & | operator *= (TimeSpan n) |
Multiply a time span. | |
TimeSpan & | operator%= (TimeSpan n) |
Compute a modulo of a time span. | |
TimeSpan & | operator+= (TimeSpan x) |
Add to a time span. | |
TimeSpan & | operator-= (TimeSpan x) |
Subtract from a time span. | |
TimeSpan & | operator/= (TimeSpan n) |
Divide a time span. | |
long | seconds (void) const |
Get the number of complete seconds in the span. | |
TimeSpan (long days, int hours, int mins, int secs, ValueType nsecs) | |
Initialise a time span to a specific length. | |
TimeSpan (ValueType secs, ValueType nsecs) | |
Initialise a time span to a specific length. | |
TimeSpan (ValueType nsecs) | |
Initialize a time span to a specific length. | |
TimeSpan (Time t) | |
Initialize a time span from Time t. | |
TimeSpan (void) | |
Initialize an empty (zero) time difference. | |
Private Attributes | |
ValueType | m_nsecs |
Friends | |
class | Time |
In addition to supporting normal integer artihmetic and comparisons, the span can also be converted to a number useful units.
Definition at line 39 of file Time.h.
lat::TimeSpan::TimeSpan | ( | void | ) | [inline] |
Initialize an empty (zero) time difference.
Definition at line 317 of file Time.h.
Referenced by lat::operator *(), lat::operator%(), lat::operator+(), lat::operator-(), and lat::operator/().
00318 : m_nsecs (0) 00319 {}
lat::TimeSpan::TimeSpan | ( | Time | t | ) | [inline] |
lat::TimeSpan::TimeSpan | ( | ValueType | nsecs | ) | [inline] |
Initialise a time span to a specific length.
The value is initialised to the sum of the parts---the parts do not need to fall into their "natural" ranges. The values are normalised to the natural meanings (e.g. 1000 seconds - 500 nanoseconds), so be careful with signs if you are producing values from other sources.
secs | Seconds. | |
nsecs | Nanoseconds. |
Definition at line 342 of file Time.h.
References m_nsecs, and lat::TimeConst::SEC_NSECS.
00343 { m_nsecs = secs * TimeConst::SEC_NSECS + nsecs; }
Initialise a time span to a specific length.
The value is initialised to the sum of the parts---the parts do not need to fall into their "natural" ranges. The values are normalised to the natural meanings (e.g. 1000 seconds - 500 nanoseconds), so be careful with signs if you are producing values from other sources.
days | Whole days. | |
hours | Whole hours. | |
mins | Whole minutes. | |
secs | Whole seconds. | |
nsecs | Nanoseconds. |
Definition at line 357 of file Time.h.
References m_nsecs, and lat::TimeConst::SEC_NSECS.
00358 { m_nsecs = (secs + 60 * (mins + 60 * (hours + 24*days)))*TimeConst::SEC_NSECS + nsecs; }
long lat::TimeSpan::days | ( | void | ) | const [inline] |
Get the number of complete days in the span.
Definition at line 362 of file Time.h.
References m_nsecs, lat::TimeConst::SEC_NSECS, and lat::TimeConst::SECS_PER_DAY.
Referenced by lastHours().
00363 { return long(m_nsecs / TimeConst::SEC_NSECS / TimeConst::SECS_PER_DAY); }
long lat::TimeSpan::hours | ( | void | ) | const [inline] |
Get the number of complete hours in the span.
Definition at line 367 of file Time.h.
References m_nsecs, lat::TimeConst::SEC_NSECS, and lat::TimeConst::SECS_PER_HOUR.
Referenced by lastHours(), and lastMinutes().
00368 { return long(m_nsecs / TimeConst::SEC_NSECS / TimeConst::SECS_PER_HOUR); }
long lat::TimeSpan::lastHours | ( | void | ) | const [inline] |
long lat::TimeSpan::lastMinutes | ( | void | ) | const [inline] |
long lat::TimeSpan::lastNSeconds | ( | void | ) | const [inline] |
Get the number of nanoseconds in the last incomplete second of the span.
Definition at line 406 of file Time.h.
References m_nsecs, and lat::TimeConst::SEC_NSECS.
00407 { return long(m_nsecs % TimeConst::SEC_NSECS); }
long lat::TimeSpan::lastSeconds | ( | void | ) | const [inline] |
long lat::TimeSpan::minutes | ( | void | ) | const [inline] |
Get the number of complete minutes in the span.
Definition at line 372 of file Time.h.
References m_nsecs, and lat::TimeConst::SEC_NSECS.
Referenced by lastMinutes(), and lastSeconds().
00373 { return long(m_nsecs / TimeConst::SEC_NSECS / 60); }
TimeSpan::ValueType lat::TimeSpan::ns | ( | void | ) | const [inline] |
Return the time span as nanoseconds.
Definition at line 382 of file Time.h.
References m_nsecs.
Referenced by lat::operator *(), lat::operator!(), lat::operator!=(), lat::operator%(), lat::operator+(), lat::operator-(), lat::operator/(), lat::operator<(), lat::operator<=(), lat::operator==(), lat::operator>(), and lat::operator>=().
00383 { return m_nsecs; }
long lat::TimeSpan::seconds | ( | void | ) | const [inline] |
Get the number of complete seconds in the span.
Definition at line 377 of file Time.h.
References m_nsecs, and lat::TimeConst::SEC_NSECS.
Referenced by lastSeconds().
00378 { return long(m_nsecs / TimeConst::SEC_NSECS); }
friend class Time [friend] |
ValueType lat::TimeSpan::m_nsecs [private] |
Definition at line 73 of file Time.h.
Referenced by days(), hours(), lastNSeconds(), minutes(), ns(), operator *=(), operator%=(), lat::Time::operator+=(), operator+=(), lat::Time::operator-=(), operator-=(), operator/=(), seconds(), and TimeSpan().