From ff693eba441b291c839f1184df97139ea472be6d Mon Sep 17 00:00:00 2001 From: Karsten Heimrich Date: Wed, 5 Nov 2008 23:23:02 +0000 Subject: [PATCH] * 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 --- headers/private/shared/DateTime.h | 4 ++-- src/kits/shared/DateTime.cpp | 11 ++++++----- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/headers/private/shared/DateTime.h b/headers/private/shared/DateTime.h index f9143de8fc..d5f4c75bed 100755 --- a/headers/private/shared/DateTime.h +++ b/headers/private/shared/DateTime.h @@ -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; diff --git a/src/kits/shared/DateTime.cpp b/src/kits/shared/DateTime.cpp index ac02eea706..2fdd0a5719 100755 --- a/src/kits/shared/DateTime.cpp +++ b/src/kits/shared/DateTime.cpp @@ -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 +