#include <vpr/Util/DateTime.h>
Public Member Functions | |
| DateTime () | |
| Constructs an empty time object. | |
| void | setNow () |
| Updates this object to reflect the current time. | |
| vpr::Uint32 | getSeconds () |
| Get the seconds since the Epoch for this object. | |
| double | getSecondsf () |
| Get the seconds (and microseconds) since the Epoch for this object. | |
| vpr::Uint32 | getMinutes () |
| Get the minutes since the Epoch for this object. | |
| double | getMinutesf () |
| Get the minutes since the Epoch for this object with floating-point precision. | |
| vpr::Uint32 | getHours () |
| Get the hours since the Epoch for this object. | |
| double | getHoursf () |
| Get the hours since the Epoch for this object with floating-point precision. | |
| vpr::Uint32 | getDays () |
| Get the days since the Epoch for this object. | |
| double | getDaysf () |
| Get the days since the Epoch for this object with floating-point precision. | |
| vpr::Uint32 | getWeeks () |
| Get the weeks since the Epoch for this object. | |
| double | getWeeksf () |
| Get the weeks since the Epoch for this object with floating-point precision. | |
| DateTime | operator+ (const DateTime &o) const |
| Overloaded addition operator for adding this and another DateTime object. | |
| DateTime | operator- (const DateTime &o) const |
| Overloaded addition operator for subtracting another DateTime object from this one. | |
Definition at line 57 of file DateTime.h.
| vpr::DateTime::DateTime | ( | ) | [inline] |
Constructs an empty time object.
To assign this object the current time, invoke setNow on it.
Definition at line 66 of file DateTime.h.
Referenced by operator+(), and operator-().
| void vpr::DateTime::setNow | ( | ) | [inline] |
Updates this object to reflect the current time.
Definition at line 79 of file DateTime.h.
References vpr::SystemPosix::gettimeofday(), vpr::TimeVal::tv_sec, and vpr::TimeVal::tv_usec.
Referenced by vpr::StatCollector< TYPE, TimeBased >::addSample(), vpr::SampleLimitedStatCollector< TYPE, TimeBased >::addSample(), vpr::StatCollector< TYPE, TimeBased >::getMean(), and vpr::SampleLimitedStatCollector< TYPE, TimeBased >::getMean().
00080 { 00081 vpr::TimeVal tv; 00082 00083 vpr::System::gettimeofday(&tv); 00084 mSeconds = tv.tv_sec; 00085 mMicroSeconds = tv.tv_usec; 00086 }
| vpr::Uint32 vpr::DateTime::getSeconds | ( | ) | [inline] |
Get the seconds since the Epoch for this object.
Definition at line 95 of file DateTime.h.
| double vpr::DateTime::getSecondsf | ( | ) | [inline] |
Get the seconds (and microseconds) since the Epoch for this object.
Definition at line 107 of file DateTime.h.
Referenced by getDaysf(), getHoursf(), vpr::StatCollector< TYPE, TimeBased >::getMean(), vpr::SampleLimitedStatCollector< TYPE, TimeBased >::getMean(), getMinutesf(), and getWeeksf().
00108 { 00109 double sec_f, usec_f, usec_f_div; 00110 00111 sec_f = (double) mSeconds; 00112 usec_f = (double) mMicroSeconds; 00113 usec_f_div = usec_f / 1000000.0f; 00114 00115 return sec_f + usec_f_div; 00116 }
| vpr::Uint32 vpr::DateTime::getMinutes | ( | ) | [inline] |
Get the minutes since the Epoch for this object.
Definition at line 125 of file DateTime.h.
| double vpr::DateTime::getMinutesf | ( | ) | [inline] |
Get the minutes since the Epoch for this object with floating-point precision.
Definition at line 138 of file DateTime.h.
References getSecondsf().
Referenced by vpr::StatCollector< TYPE, TimeBased >::print(), and vpr::SampleLimitedStatCollector< TYPE, TimeBased >::print().
00139 { 00140 return getSecondsf() / 60.0f; 00141 }
| vpr::Uint32 vpr::DateTime::getHours | ( | ) | [inline] |
Get the hours since the Epoch for this object.
Definition at line 150 of file DateTime.h.
| double vpr::DateTime::getHoursf | ( | ) | [inline] |
Get the hours since the Epoch for this object with floating-point precision.
Definition at line 163 of file DateTime.h.
References getSecondsf().
00164 { 00165 return getSecondsf() / 3600.0f; 00166 }
| vpr::Uint32 vpr::DateTime::getDays | ( | ) | [inline] |
Get the days since the Epoch for this object.
Definition at line 175 of file DateTime.h.
| double vpr::DateTime::getDaysf | ( | ) | [inline] |
Get the days since the Epoch for this object with floating-point precision.
Definition at line 188 of file DateTime.h.
References getSecondsf().
00189 { 00190 return getSecondsf() / 86400.0f; 00191 }
| vpr::Uint32 vpr::DateTime::getWeeks | ( | ) | [inline] |
Get the weeks since the Epoch for this object.
Definition at line 200 of file DateTime.h.
| double vpr::DateTime::getWeeksf | ( | ) | [inline] |
Get the weeks since the Epoch for this object with floating-point precision.
Definition at line 213 of file DateTime.h.
References getSecondsf().
00214 { 00215 return getSecondsf() / 608400.0f; 00216 }
Overloaded addition operator for adding this and another DateTime object.
Definition at line 222 of file DateTime.h.
References DateTime(), mMicroSeconds, and mSeconds.
00223 { 00224 const vpr::Uint32 us = mMicroSeconds + o.mMicroSeconds; 00225 if ( us > 1000000 ) 00226 { 00227 return DateTime(mSeconds + o.mSeconds + 1, us - 1000000); 00228 } 00229 else 00230 { 00231 return DateTime(mSeconds + o.mSeconds, us); 00232 } 00233 }
Overloaded addition operator for subtracting another DateTime object from this one.
Definition at line 239 of file DateTime.h.
References DateTime(), mMicroSeconds, and mSeconds.
00240 { 00241 if ( mMicroSeconds > o.mMicroSeconds ) 00242 { 00243 return DateTime(mSeconds - o.mSeconds, 00244 mMicroSeconds - o.mMicroSeconds); 00245 } 00246 else 00247 { 00248 return DateTime(mSeconds - o.mSeconds - 1, 00249 1000000 + mMicroSeconds - o.mMicroSeconds); 00250 } 00251 }
1.5.1