X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Ftime%2Fgadgets.cc;fp=src%2Ftime%2Fgadgets.cc;h=d542dfacd4ff738f1ca697568ac5c7a3692169ba;hb=3d0d2c1a6ba0efb2789710635a7d9f692e49b3b0;hp=3ab1b87bcfcbbcfe8ce6396ee252e50c06232a19;hpb=01be15327511b5192cd728f5ee798e2e27b2fba5;p=thirdparty%2Fsquid.git diff --git a/src/time/gadgets.cc b/src/time/gadgets.cc index 3ab1b87bcf..d542dfacd4 100644 --- a/src/time/gadgets.cc +++ b/src/time/gadgets.cc @@ -11,6 +11,7 @@ #include "squid.h" #include "time/gadgets.h" +#include #include #include @@ -21,12 +22,11 @@ time_t squid_curtime = 0; time_t getCurrentTime() { -#if GETTIMEOFDAY_NO_TZP - gettimeofday(¤t_time); -#else + using namespace std::chrono; + const auto now = system_clock::now().time_since_epoch(); - gettimeofday(¤t_time, nullptr); -#endif + current_time.tv_sec = duration_cast(now).count(); + current_time.tv_usec = duration_cast(now).count() % 1000000; current_dtime = (double) current_time.tv_sec + (double) current_time.tv_usec / 1000000.0;