28 #include "TimeValue.h"
30 namespace com {
namespace avpkit {
namespace core {
32 static int64_t sConversionTable[7][7] =
34 { 1, 24, 1440, 86400, 86400000, 86400000000LL, 86400000000000LL },
35 { 0, 1, 60, 3600, 3600000, 3600000000LL, 3600000000000LL },
36 { 0, 0, 1, 60, 60000, 60000000LL, 60000000000LL },
37 { 0, 0, 0, 1, 1000, 1000000LL, 1000000000LL },
38 { 0, 0, 0, 0, 1, 1000LL, 1000000LL },
39 { 0, 0, 0, 0, 0, 1LL, 1000LL },
40 { 0, 0, 0, 0, 0, 0LL, 1LL },
43 TimeValue::TimeValue()
49 TimeValue::~TimeValue()
54 TimeValue::set(int64_t value, Unit unit)
61 TimeValue::make(int64_t value, Unit unit)
63 TimeValue *retval = make();
65 retval->set(value, unit);
70 TimeValue::make(TimeValue * src)
74 return make(src->mValue, src->mUnit);
78 TimeValue::getNativeUnit()
90 bool multiply =
false;
91 int64_t factor = sConversionTable[aUnit][mUnit];
94 factor = sConversionTable[mUnit][aUnit];
98 retval = mValue * factor;
100 retval = mValue / factor;
113 Unit thisUnit = this->getNativeUnit();
114 Unit thatUnit = that->getNativeUnit();
117 Unit minUnit = thisUnit > thatUnit ? thisUnit : thatUnit;
119 int64_t thisValue = this->
get(minUnit);
120 int64_t thatValue = that->
get(minUnit);
121 retval = TimeValue::compare(thisValue, thatValue);
Time (duration) values with units.
virtual int32_t compareTo(ITimeValue *other)
Compare this timeValue to another.
virtual int64_t get(Unit unit)
Get the value of this ITimeValue, in the specified Unit.
WARNING: Do not use logging in this class, and do not set any static file variables to values other t...