From 672bc3ab671e59691cbafdb48a71f38ed3735b04 Mon Sep 17 00:00:00 2001
From: Max Kellermann <max@musicpd.org>
Date: Tue, 17 Mar 2020 16:59:21 +0100
Subject: [PATCH] time/Convert: fix GetTimeZoneOffset() on Windows

Was using the wrong parameter.
---
 NEWS                 | 2 ++
 src/time/Convert.cxx | 6 +++---
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/NEWS b/NEWS
index 0e9346ea6..ec8566280 100644
--- a/NEWS
+++ b/NEWS
@@ -9,6 +9,8 @@ ver 0.21.22 (not yet released)
   - android: new mixer plugin for "sles" output
 * Android
   - TV support
+* Windows
+  - fix time zone offset check
 * fix build failures with uClibc-ng
 
 ver 0.21.21 (2020/03/19)
diff --git a/src/time/Convert.cxx b/src/time/Convert.cxx
index 2351f4b52..352c60604 100644
--- a/src/time/Convert.cxx
+++ b/src/time/Convert.cxx
@@ -77,15 +77,15 @@ static time_t
 GetTimeZoneOffset() noexcept
 {
 	time_t t = 1234567890;
-	struct tm tm;
-	tm.tm_isdst = 0;
 #ifdef _WIN32
 	struct tm *p = gmtime(&t);
 #else
+	struct tm tm;
+	tm.tm_isdst = 0;
 	struct tm *p = &tm;
 	gmtime_r(&t, p);
 #endif
-	return t - mktime(&tm);
+	return t - mktime(p);
 }
 
 #endif /* !__GLIBC__ */