* fix wrong cast in Minute()
* fix _SetTime(), was using the wrong * operator, resulting in an overflow at some point that lead to the mentioned jumping fixes 2878 and 3057 git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@28524 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
28f40a0eff
commit
ff693eba44
|
@ -71,8 +71,8 @@ class BTime {
|
|||
private:
|
||||
bigtime_t _Microseconds() const;
|
||||
void _AddMicroseconds(bigtime_t microseconds);
|
||||
bool _SetTime(int32 hour, int32 minute, int32 second,
|
||||
int32 microsecond);
|
||||
bool _SetTime(bigtime_t hour, bigtime_t minute, bigtime_t second,
|
||||
bigtime_t microsecond);
|
||||
|
||||
private:
|
||||
bigtime_t fMicroseconds;
|
||||
|
|
|
@ -24,8 +24,8 @@ const int32 kMinutesPerDay = 1440;
|
|||
const int32 kSecondsPerDay = 86400;
|
||||
const int32 kMillisecondsPerDay = 86400000;
|
||||
|
||||
const int32 kMicrosecondsPerSecond = 1000000;
|
||||
const int32 kMicrosecondsPerMinute = 60000000;
|
||||
const bigtime_t kMicrosecondsPerSecond = 1000000LL;
|
||||
const bigtime_t kMicrosecondsPerMinute = 60000000LL;
|
||||
const bigtime_t kMicrosecondsPerHour = 3600000000LL;
|
||||
const bigtime_t kMicrosecondsPerDay = 86400000000LL;
|
||||
|
||||
|
@ -70,7 +70,7 @@ BTime::IsValid(int32 hour, int32 minute, int32 second, int32 microsecond) const
|
|||
|
||||
|
||||
BTime
|
||||
BTime::CurrentTime(time_type type)
|
||||
BTime::CurrentTime(time_type type)
|
||||
{
|
||||
struct timeval tv;
|
||||
if (gettimeofday(&tv, NULL) != 0) {
|
||||
|
@ -162,7 +162,7 @@ BTime::Hour() const
|
|||
int32
|
||||
BTime::Minute() const
|
||||
{
|
||||
return int32((_Microseconds() % kMicrosecondsPerHour)) / kMicrosecondsPerMinute;
|
||||
return int32(((_Microseconds() % kMicrosecondsPerHour)) / kMicrosecondsPerMinute);
|
||||
}
|
||||
|
||||
|
||||
|
@ -274,7 +274,8 @@ BTime::_AddMicroseconds(bigtime_t microseconds)
|
|||
|
||||
|
||||
bool
|
||||
BTime::_SetTime(int32 hour, int32 minute, int32 second, int32 microsecond)
|
||||
BTime::_SetTime(bigtime_t hour, bigtime_t minute, bigtime_t second,
|
||||
bigtime_t microsecond)
|
||||
{
|
||||
fMicroseconds = hour * kMicrosecondsPerHour +
|
||||
minute * kMicrosecondsPerMinute +
|
||||
|
|
Loading…
Reference in New Issue