diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-11-30 14:49:08 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2015-11-30 14:49:57 +0100 |
commit | 34e02e0147188a7e364489db23128a05505e7a4c (patch) | |
tree | 92d2bfeab7ae0bb85e34949760d0d29013c19a75 /src | |
parent | eb7741605b32c25893f687e19820dab114d04fe1 (diff) | |
parent | 1bb289fe1b7d240e0d58ef13da30e45590231078 (diff) |
Merge pull request #7094
1bb289f Assert now > 0 in GetTime GetTimeMillis GetTimeMicros (Patick Strateman)
Diffstat (limited to 'src')
-rw-r--r-- | src/utiltime.cpp | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/src/utiltime.cpp b/src/utiltime.cpp index 3202c47f1d..7d9f6210eb 100644 --- a/src/utiltime.cpp +++ b/src/utiltime.cpp @@ -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) @@ -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 */ |