Skip to content

Commit

Permalink
Merge pull request #163 from marcgurevitx/fix-daylight
Browse files Browse the repository at this point in the history
Consider daylight savings in _dateStr()
  • Loading branch information
JoeStrout authored Jul 28, 2024
2 parents 2ced9d8 + db98690 commit 15c1ca8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions MiniScript-cpp/src/DateTimeUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
14 changes: 14 additions & 0 deletions MiniScript-cpp/tests/testDaylight.ms
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 15c1ca8

Please sign in to comment.