aboutsummaryrefslogtreecommitdiffstats
path: root/src/redshift.c
diff options
context:
space:
mode:
authorMasanori Kakura <kakurasan@gmail.com>2019-10-02 22:24:22 +0900
committerMasanori Kakura <kakurasan@gmail.com>2019-10-02 22:24:22 +0900
commit1da93dcd7d4abf3bc3b46e192e940d80c39465df (patch)
tree4e9cc9d730894b1d56826a47c467458a8c7ec494 /src/redshift.c
parentMerge pull request #710 from hubvu/suspend-feature (diff)
downloadredshift-ng-1da93dcd7d4abf3bc3b46e192e940d80c39465df.tar.gz
redshift-ng-1da93dcd7d4abf3bc3b46e192e940d80c39465df.tar.bz2
redshift-ng-1da93dcd7d4abf3bc3b46e192e940d80c39465df.tar.xz
src/redshift.c: Use localtime_s() on Windows
AppVeyor's GCC no longer supports localtime_r(). We need to use localtime_s() on Windows.
Diffstat (limited to '')
-rw-r--r--src/redshift.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/redshift.c b/src/redshift.c
index e0221d5..d2ba577 100644
--- a/src/redshift.c
+++ b/src/redshift.c
@@ -28,6 +28,7 @@
#include <math.h>
#include <locale.h>
#include <errno.h>
+#include <time.h>
/* poll.h is not available on Windows but there is no Windows location provider
using polling. On Windows, we just define some stubs to make things compile.
@@ -210,7 +211,11 @@ get_seconds_since_midnight(double timestamp)
{
time_t t = (time_t)timestamp;
struct tm tm;
+#ifdef _WIN32
+ localtime_s(&tm, &t);
+#else
localtime_r(&t, &tm);
+#endif
return tm.tm_sec + tm.tm_min * 60 + tm.tm_hour * 3600;
}