From 734e2a0381b134d45148a9e159f5170ccf6ffc6d Mon Sep 17 00:00:00 2001 From: Marc Gurevitx Date: Mon, 15 Jul 2024 13:37:53 +0200 Subject: [PATCH] Fix for #159 --- MiniScript-cpp/src/DateTimeUtils.cpp | 1 + MiniScript-cpp/tests/testDaylight.ms | 14 ++++++++++++++ 2 files changed, 15 insertions(+) create mode 100644 MiniScript-cpp/tests/testDaylight.ms diff --git a/MiniScript-cpp/src/DateTimeUtils.cpp b/MiniScript-cpp/src/DateTimeUtils.cpp index 8cf5984..0bc1b18 100644 --- a/MiniScript-cpp/src/DateTimeUtils.cpp +++ b/MiniScript-cpp/src/DateTimeUtils.cpp @@ -307,6 +307,7 @@ time_t ParseDate(const String dateStr) { dateTime.tm_mon = now.tm_mon; dateTime.tm_mday = now.tm_mday; } + dateTime.tm_isdst = -1; return mktime(&dateTime); } diff --git a/MiniScript-cpp/tests/testDaylight.ms b/MiniScript-cpp/tests/testDaylight.ms new file mode 100644 index 0000000..7a7380d --- /dev/null +++ b/MiniScript-cpp/tests/testDaylight.ms @@ -0,0 +1,14 @@ +import "qa" + +testDaylight = function + + // This test always only tests a half of functionality depending on whether the host system has "daylight savings" on or off. + + d = "2000-01-01 11:00:00" + qa.assertEqual _dateStr(d, "%H"), "11" + + d = "2000-07-01 11:00:00" + qa.assertEqual _dateStr(d, "%H"), "11" +end function + +if refEquals(locals, globals) then testDaylight