Skip to content

Commit

Permalink
Merge pull request #7094
Browse files Browse the repository at this point in the history
1bb289f Assert now > 0 in GetTime GetTimeMillis GetTimeMicros (Patick Strateman)
  • Loading branch information
laanwj committed Nov 30, 2015
2 parents eb77416 + 1bb289f commit 34e02e0
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions src/utiltime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,9 @@ int64_t GetTime()
{
if (nMockTime) return nMockTime;

return time(NULL);
time_t now = time(NULL);
assert(now > 0);
return now;
}

void SetMockTime(int64_t nMockTimeIn)
Expand All @@ -30,14 +32,18 @@ void SetMockTime(int64_t nMockTimeIn)

int64_t GetTimeMillis()
{
return (boost::posix_time::microsec_clock::universal_time() -
boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();
int64_t now = (boost::posix_time::microsec_clock::universal_time() -
boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_milliseconds();
assert(now > 0);
return now;
}

int64_t GetTimeMicros()
{
return (boost::posix_time::microsec_clock::universal_time() -
boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_microseconds();
int64_t now = (boost::posix_time::microsec_clock::universal_time() -
boost::posix_time::ptime(boost::gregorian::date(1970,1,1))).total_microseconds();
assert(now > 0);
return now;
}

/** Return a time useful for the debug log */
Expand Down

0 comments on commit 34e02e0

Please sign in to comment.