]> granicus.if.org Git - icinga2/blobdiff - test/icinga-legacytimeperiod.cpp
Merge pull request #6544 from gunnarbeutner/fix/deprecated-strstream-header
[icinga2] / test / icinga-legacytimeperiod.cpp
index df93fd817421e69da2b001607db2c30f1988cd36..f178934c943bcad4277ee75a6fa0029ecc110478 100644 (file)
@@ -1,6 +1,6 @@
 /******************************************************************************
  * Icinga 2                                                                   *
- * Copyright (C) 2012-2016 Icinga Development Team (https://www.icinga.org/)  *
+ * Copyright (C) 2012-2018 Icinga Development Team (https://www.icinga.org/)  *
  *                                                                            *
  * This program is free software; you can redistribute it and/or              *
  * modify it under the terms of the GNU General Public License                *
@@ -18,7 +18,7 @@
  ******************************************************************************/
 
 #include "icinga/legacytimeperiod.hpp"
-#include <boost/test/unit_test.hpp>
+#include <BoostTestTargetConfig.h>
 
 using namespace icinga;
 
@@ -28,19 +28,30 @@ struct GlobalTimezoneFixture
 {
        char *tz;
 
-       GlobalTimezoneFixture(void)
+       GlobalTimezoneFixture()
        {
                tz = getenv("TZ");
+#ifdef _WIN32
+               _putenv_s("TZ", "UTC");
+#else
                setenv("TZ", "", 1);
+#endif
                tzset();
        }
 
-       ~GlobalTimezoneFixture(void)
+       ~GlobalTimezoneFixture()
        {
+#ifdef _WIN32
+               if (tz)
+                       _putenv_s("TZ", tz);
+               else
+                       _putenv_s("TZ", "");
+#else
                if (tz)
                        setenv("TZ", tz, 1);
                else
                        unsetenv("TZ");
+#endif
                tzset();
        }
 };
@@ -50,7 +61,6 @@ BOOST_GLOBAL_FIXTURE(GlobalTimezoneFixture);
 BOOST_AUTO_TEST_CASE(simple)
 {
        tm beg, end, ref;
-       timegm(&ref);
 
        // check parsing of "YYYY-MM-DD" specs
        LegacyTimePeriod::ParseTimeSpec("2016-01-01", &beg, &end, &ref);