Skip to content

Commit 15c1ca8

Browse files
authored
Merge pull request #163 from marcgurevitx/fix-daylight
Consider daylight savings in _dateStr()
2 parents 2ced9d8 + db98690 commit 15c1ca8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

MiniScript-cpp/src/DateTimeUtils.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -307,6 +307,7 @@ time_t ParseDate(const String dateStr) {
307307
dateTime.tm_mon = now.tm_mon;
308308
dateTime.tm_mday = now.tm_mday;
309309
}
310+
dateTime.tm_isdst = -1;
310311
return mktime(&dateTime);
311312
}
312313

MiniScript-cpp/tests/testDaylight.ms

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import "qa"
2+
3+
testDaylight = function
4+
5+
// This test always only tests a half of functionality depending on whether the host system has "daylight savings" on or off.
6+
7+
d = "2000-01-01 11:00:00"
8+
qa.assertEqual _dateStr(d, "%H"), "11"
9+
10+
d = "2000-07-01 11:00:00"
11+
qa.assertEqual _dateStr(d, "%H"), "11"
12+
end function
13+
14+
if refEquals(locals, globals) then testDaylight

0 commit comments

Comments
 (0)