| 1071 | // DateTime |
| 1072 | |
| 1073 | void DateTime::gettimeofday(struct timeval* tv) { |
| 1074 | #if ELPP_OS_WINDOWS |
| 1075 | if (tv != nullptr) { |
| 1076 | # if ELPP_COMPILER_MSVC || defined(_MSC_EXTENSIONS) |
| 1077 | const unsigned __int64 delta_ = 11644473600000000Ui64; |
| 1078 | # else |
| 1079 | const unsigned __int64 delta_ = 11644473600000000ULL; |
| 1080 | # endif // ELPP_COMPILER_MSVC || defined(_MSC_EXTENSIONS) |
| 1081 | const double secOffSet = 0.000001; |
| 1082 | const unsigned long usecOffSet = 1000000; |
| 1083 | FILETIME fileTime; |
| 1084 | GetSystemTimeAsFileTime(&fileTime); |
| 1085 | unsigned __int64 present = 0; |
| 1086 | present |= fileTime.dwHighDateTime; |
| 1087 | present = present << 32; |
| 1088 | present |= fileTime.dwLowDateTime; |
| 1089 | present /= 10; // mic-sec |
| 1090 | // Subtract the difference |
| 1091 | present -= delta_; |
| 1092 | tv->tv_sec = static_cast<long>(present * secOffSet); |
| 1093 | tv->tv_usec = static_cast<long>(present % usecOffSet); |
| 1094 | } |
| 1095 | #else |
| 1096 | ::gettimeofday(tv, nullptr); |
| 1097 | #endif // ELPP_OS_WINDOWS |
| 1098 | } |
| 1099 | |
| 1100 | std::string DateTime::getDateTime(const char* format, const base::SubsecondPrecision* ssPrec) { |
| 1101 | struct timeval currTime; |
nothing calls this directly
no outgoing calls
no test coverage detected