Open kseistrup opened 1 month ago
Oh, dateTime.hour()
expects a .nowVal
, not a .now
…
.hour()
calls _dateStr()
which should handle both of those...
@kseistrup : Is your area affected by "daylight savings"? If so, maybe this issue should be reopened.
@marcgurevitx
Is your area affected by "daylight savings"?
Yes, I'm in Europe/Copenhagen
: currently CEST (UTC+2), normally CET (UTC+1).
I am completely new to miniscript (after it was mentioned on lobste.rs) and wrote a short script in miniscript:
https://codeberg.org/kas/qtime/src/branch/master/miniscript/qtime.ms
It works with .nowVal
, but not with .now
. I will reopen this issue then.
edit: typo
@kseistrup Can you edit the source and add
dateTime.tm_isdst = -1;
right before this call to mktime() in DateTimeUtils.cpp, line 307 ?
It fixes the issue on my machine when I "pretend" that I'm in Copenhagen. Want to be sure that for the real Copenhagen it works as well.
@marcgurevitx
After adding that line dateTime.hour(date)
gives the right answer both when date
is a .now
and a .nowVal
.
Using faketime
, it also seems to work for dates when Denmark has switched back to normal time. This goes well with what mktime(3)
says abouit the tm_isdst
field, but I'm unsure how reliable results obtained with faketime
is in this context.
For now the addition seems to have solved the issue.
Thanks :pray:
In the following I expected
dateTime.hour(now)
to return16
, instead I got17
: