31.10.2017, 06:46
What about time zone and time shift? Please be carefull especially with the time shift because after it your calculations can be offset by 1 hour.
Code:
isdst = os.date('*t').isdst
if isdst then d = d - 3600 end