From 0c862e371eefadb4941ba0bf9019c57409e098f9 Mon Sep 17 00:00:00 2001 From: Gargaj Date: Fri, 17 May 2024 16:39:18 +0200 Subject: [PATCH 1/2] replace older time functions with more portable ones As per https://www.gnu.org/software/libc/manual/html_node/Broken_002ddown-Time.html --- implot.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/implot.cpp b/implot.cpp index 597b043b..50fd891b 100644 --- a/implot.cpp +++ b/implot.cpp @@ -909,7 +909,7 @@ ImPlotTime MkGmtTime(struct tm *ptm) { #ifdef _WIN32 t.S = _mkgmtime(ptm); #else - t.S = timegm(ptm); + t.S = mktime(ptm); #endif if (t.S < 0) t.S = 0; @@ -924,7 +924,7 @@ tm* GetGmtTime(const ImPlotTime& t, tm* ptm) else return nullptr; #else - return gmtime_r(&t.S, ptm); + return gmtime_s(&t.S, ptm); #endif } @@ -943,7 +943,7 @@ tm* GetLocTime(const ImPlotTime& t, tm* ptm) { else return nullptr; #else - return localtime_r(&t.S, ptm); + return localtime_s(&t.S, ptm); #endif } From 154dac3e3bf1d939fc43bf6cbe8da6d9167eed5c Mon Sep 17 00:00:00 2001 From: Gargaj Date: Mon, 20 May 2024 18:39:07 +0200 Subject: [PATCH 2/2] use __STDC_WANT_LIB_EXT1__ to distinguish use cases --- implot.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/implot.cpp b/implot.cpp index 50fd891b..eea3116e 100644 --- a/implot.cpp +++ b/implot.cpp @@ -923,8 +923,10 @@ tm* GetGmtTime(const ImPlotTime& t, tm* ptm) return ptm; else return nullptr; -#else +#elif defined(__STDC_WANT_LIB_EXT1__) return gmtime_s(&t.S, ptm); +#else + return gmtime_r(&t.S, ptm); #endif } @@ -942,8 +944,10 @@ tm* GetLocTime(const ImPlotTime& t, tm* ptm) { return ptm; else return nullptr; -#else +#elif defined(__STDC_WANT_LIB_EXT1__) return localtime_s(&t.S, ptm); +#else + return localtime_r(&t.S, ptm); #endif }