@@ -24,49 +24,6 @@ void UninterruptibleSleep(const std::chrono::microseconds& n) { std::this_thread
2424
2525static std::atomic<int64_t > nMockTime (0 ); // !< For testing
2626
27- bool ChronoSanityCheck ()
28- {
29- // std::chrono::system_clock.time_since_epoch and time_t(0) are not guaranteed
30- // to use the Unix epoch timestamp, prior to C++20, but in practice they almost
31- // certainly will. Any differing behavior will be assumed to be an error, unless
32- // certain platforms prove to consistently deviate, at which point we'll cope
33- // with it by adding offsets.
34-
35- // Create a new clock from time_t(0) and make sure that it represents 0
36- // seconds from the system_clock's time_since_epoch. Then convert that back
37- // to a time_t and verify that it's the same as before.
38- const time_t time_t_epoch{};
39- auto clock = std::chrono::system_clock::from_time_t (time_t_epoch);
40- if (std::chrono::duration_cast<std::chrono::seconds>(clock.time_since_epoch ()).count () != 0 ) {
41- return false ;
42- }
43-
44- time_t time_val = std::chrono::system_clock::to_time_t (clock);
45- if (time_val != time_t_epoch) {
46- return false ;
47- }
48-
49- // Check that the above zero time is actually equal to the known unix timestamp.
50- struct tm epoch;
51- #ifdef HAVE_GMTIME_R
52- if (gmtime_r (&time_val, &epoch) == nullptr ) {
53- #else
54- if (gmtime_s (&epoch, &time_val) != 0 ) {
55- #endif
56- return false ;
57- }
58-
59- if ((epoch.tm_sec != 0 ) ||
60- (epoch.tm_min != 0 ) ||
61- (epoch.tm_hour != 0 ) ||
62- (epoch.tm_mday != 1 ) ||
63- (epoch.tm_mon != 0 ) ||
64- (epoch.tm_year != 70 )) {
65- return false ;
66- }
67- return true ;
68- }
69-
7027NodeClock::time_point NodeClock::now () noexcept
7128{
7229 const std::chrono::seconds mocktime{nMockTime.load (std::memory_order_relaxed)};
0 commit comments