2008-08-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>

Use time_t instead of int32_t. Use int64_t where milli second is
	expected.
	* src/TimeA2.cc
	* src/TimeA2.h
pull/1/head
Tatsuhiro Tsujikawa 2008-08-09 10:31:29 +00:00
parent 26690f692b
commit 8208e538ba
3 changed files with 21 additions and 14 deletions

View File

@ -1,3 +1,10 @@
2008-08-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Use time_t instead of int32_t. Use int64_t where milli second is
expected.
* src/TimeA2.cc
* src/TimeA2.h
2008-08-09 Tatsuhiro Tsujikawa <tujikawa at rednoah dot com>
Implemented ServerStatMan::save(...) function and its test case.

View File

@ -46,7 +46,7 @@ Time::Time(const Time& time) {
tv = time.tv;
}
Time::Time(int32_t sec) {
Time::Time(time_t sec) {
setTimeInSec(sec);
}
@ -70,7 +70,7 @@ struct timeval Time::getCurrentTime() const {
return now;
}
bool Time::elapsed(int32_t sec) const {
bool Time::elapsed(time_t sec) const {
// Because of gettimeofday called from getCurrentTime() is slow, and most of
// the time this function is called before specified time passes, we first do
// simple test using time.
@ -85,7 +85,7 @@ bool Time::elapsed(int32_t sec) const {
}
}
bool Time::elapsedInMillis(int32_t millis) const {
bool Time::elapsedInMillis(int64_t millis) const {
return Util::difftv(getCurrentTime(), tv)/1000 >= millis;
}
@ -93,11 +93,11 @@ bool Time::isNewer(const Time& time) const {
return Util::difftv(this->tv, time.tv) > 0;
}
int32_t Time::difference() const {
time_t Time::difference() const {
return Util::difftvsec(getCurrentTime(), tv);
}
int32_t Time::difference(const struct timeval& now) const
time_t Time::difference(const struct timeval& now) const
{
return Util::difftvsec(now, tv);
}
@ -126,12 +126,12 @@ int64_t Time::getTimeInMillis() const
return (int64_t)tv.tv_sec*1000+tv.tv_usec/1000;
}
int32_t Time::getTime() const
time_t Time::getTime() const
{
return tv.tv_sec;
}
void Time::setTimeInSec(int32_t sec) {
void Time::setTimeInSec(time_t sec) {
tv.tv_sec = sec;
tv.tv_usec = 0;
}

View File

@ -51,7 +51,7 @@ public:
// this object was created.
Time();
Time(const Time& time);
Time(int32_t sec);
Time(time_t sec);
Time& operator=(const Time& time);
@ -60,13 +60,13 @@ public:
// Makes this object's time value up to date.
void reset();
bool elapsed(int32_t sec) const;
bool elapsed(time_t sec) const;
bool elapsedInMillis(int32_t millis) const;
bool elapsedInMillis(int64_t millis) const;
int32_t difference() const;
time_t difference() const;
int32_t difference(const struct timeval& now) const;
time_t difference(const struct timeval& now) const;
int64_t differenceInMillis() const;
@ -80,9 +80,9 @@ public:
int64_t getTimeInMillis() const;
// Returns this object's time value in seconds.
int32_t getTime() const;
time_t getTime() const;
void setTimeInSec(int32_t sec);
void setTimeInSec(time_t sec);
bool isNewer(const Time& time) const;
};