|
|
@ -68,7 +68,6 @@ namespace details {
|
|
|
|
namespace os {
|
|
|
|
namespace os {
|
|
|
|
|
|
|
|
|
|
|
|
spdlog::log_clock::time_point now() noexcept {
|
|
|
|
spdlog::log_clock::time_point now() noexcept {
|
|
|
|
|
|
|
|
|
|
|
|
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
|
|
|
|
#if defined __linux__ && defined SPDLOG_CLOCK_COARSE
|
|
|
|
timespec ts;
|
|
|
|
timespec ts;
|
|
|
|
::clock_gettime(CLOCK_REALTIME_COARSE, &ts);
|
|
|
|
::clock_gettime(CLOCK_REALTIME_COARSE, &ts);
|
|
|
@ -81,7 +80,6 @@ spdlog::log_clock::time_point now() noexcept {
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
}
|
|
|
|
std::tm localtime(const std::time_t &time_tt) noexcept {
|
|
|
|
std::tm localtime(const std::time_t &time_tt) noexcept {
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef _WIN32
|
|
|
|
std::tm tm;
|
|
|
|
std::tm tm;
|
|
|
|
::localtime_s(&tm, &time_tt);
|
|
|
|
::localtime_s(&tm, &time_tt);
|
|
|
@ -98,7 +96,6 @@ std::tm localtime() noexcept {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::tm gmtime(const std::time_t &time_tt) noexcept {
|
|
|
|
std::tm gmtime(const std::time_t &time_tt) noexcept {
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef _WIN32
|
|
|
|
std::tm tm;
|
|
|
|
std::tm tm;
|
|
|
|
::gmtime_s(&tm, &time_tt);
|
|
|
|
::gmtime_s(&tm, &time_tt);
|
|
|
@ -243,7 +240,6 @@ size_t filesize(FILE *f) {
|
|
|
|
|
|
|
|
|
|
|
|
// Return utc offset in minutes or throw spdlog_ex on failure
|
|
|
|
// Return utc offset in minutes or throw spdlog_ex on failure
|
|
|
|
int utc_minutes_offset(const std::tm &tm) {
|
|
|
|
int utc_minutes_offset(const std::tm &tm) {
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef _WIN32
|
|
|
|
#if _WIN32_WINNT < _WIN32_WINNT_WS08
|
|
|
|
#if _WIN32_WINNT < _WIN32_WINNT_WS08
|
|
|
|
TIME_ZONE_INFORMATION tzinfo;
|
|
|
|
TIME_ZONE_INFORMATION tzinfo;
|
|
|
@ -252,8 +248,7 @@ int utc_minutes_offset(const std::tm &tm) {
|
|
|
|
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
|
|
|
|
DYNAMIC_TIME_ZONE_INFORMATION tzinfo;
|
|
|
|
auto rv = ::GetDynamicTimeZoneInformation(&tzinfo);
|
|
|
|
auto rv = ::GetDynamicTimeZoneInformation(&tzinfo);
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
if (rv == TIME_ZONE_ID_INVALID)
|
|
|
|
if (rv == TIME_ZONE_ID_INVALID) throw_spdlog_ex("Failed getting timezone info. ", errno);
|
|
|
|
throw_spdlog_ex("Failed getting timezone info. ", errno);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int offset = -tzinfo.Bias;
|
|
|
|
int offset = -tzinfo.Bias;
|
|
|
|
if (tm.tm_isdst) {
|
|
|
|
if (tm.tm_isdst) {
|
|
|
@ -379,7 +374,6 @@ std::string filename_to_str(const filename_t &filename) { return filename; }
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
int pid() noexcept {
|
|
|
|
int pid() noexcept {
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef _WIN32
|
|
|
|
return static_cast<int>(::GetCurrentProcessId());
|
|
|
|
return static_cast<int>(::GetCurrentProcessId());
|
|
|
|
#else
|
|
|
|
#else
|
|
|
@ -421,7 +415,6 @@ bool is_color_terminal() noexcept {
|
|
|
|
// Determine if the terminal attached
|
|
|
|
// Determine if the terminal attached
|
|
|
|
// Source: https://github.com/agauniyal/rang/
|
|
|
|
// Source: https://github.com/agauniyal/rang/
|
|
|
|
bool in_terminal(FILE *file) noexcept {
|
|
|
|
bool in_terminal(FILE *file) noexcept {
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef _WIN32
|
|
|
|
return ::_isatty(_fileno(file)) != 0;
|
|
|
|
return ::_isatty(_fileno(file)) != 0;
|
|
|
|
#else
|
|
|
|
#else
|
|
|
@ -546,7 +539,6 @@ filename_t dir_name(const filename_t &path) {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
std::string getenv(const char *field) {
|
|
|
|
std::string getenv(const char *field) {
|
|
|
|
|
|
|
|
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#if defined(_MSC_VER)
|
|
|
|
#if defined(__cplusplus_winrt)
|
|
|
|
#if defined(__cplusplus_winrt)
|
|
|
|
return std::string{}; // not supported under uwp
|
|
|
|
return std::string{}; // not supported under uwp
|
|
|
|