File tree Expand file tree Collapse file tree 2 files changed +8
-6
lines changed
Expand file tree Collapse file tree 2 files changed +8
-6
lines changed Original file line number Diff line number Diff line change @@ -37,18 +37,20 @@ int64_t GetMockTime()
3737 return nMockTime.load (std::memory_order_relaxed);
3838}
3939
40- int64_t GetTimeMillis ()
40+ int64_t GetTimeMillis () noexcept
4141{
42+ static const boost::posix_time::ptime epoch = boost::posix_time::from_time_t (0 );
4243 int64_t now = (boost::posix_time::microsec_clock::universal_time () -
43- boost::posix_time::ptime ( boost::gregorian::date ( 1970 , 1 , 1 )) ).total_milliseconds ();
44+ epoch ).total_milliseconds ();
4445 assert (now > 0 );
4546 return now;
4647}
4748
48- int64_t GetTimeMicros ()
49+ int64_t GetTimeMicros () noexcept
4950{
51+ static const boost::posix_time::ptime epoch = boost::posix_time::from_time_t (0 );
5052 int64_t now = (boost::posix_time::microsec_clock::universal_time () -
51- boost::posix_time::ptime ( boost::gregorian::date ( 1970 , 1 , 1 )) ).total_microseconds ();
53+ epoch ).total_microseconds ();
5254 assert (now > 0 );
5355 return now;
5456}
Original file line number Diff line number Diff line change 2020 */
2121
2222int64_t GetTime ();
23- int64_t GetTimeMillis ();
24- int64_t GetTimeMicros ();
23+ int64_t GetTimeMillis () noexcept ;
24+ int64_t GetTimeMicros () noexcept ;
2525int64_t GetSystemTimeInSeconds (); // Like GetTime(), but not mockable
2626void SetMockTime (int64_t nMockTimeIn);
2727int64_t GetMockTime ();
You can’t perform that action at this time.
0 commit comments