20 lines
1.3 KiB
Plaintext
20 lines
1.3 KiB
Plaintext
-- Simple unit test to test time zones
|
|
|
|
dofile("../timecore.lua")
|
|
|
|
SUMMERTIME_OFFSET=2
|
|
WINTERTIME_OFFSET=1
|
|
|
|
-- This functions expects to be executed in Germany,
|
|
-- so resultingHourDiff is 1 in wintertime
|
|
-- and 2 in summertime
|
|
function checkTime(yearIn, monthIn, dayIn, hourIn, minutesIn, secondsIn,dowIn, resultingHourDiff)
|
|
local summerTime = isSummerTime(yearIn, monthIn, dayIn, hourIn, minutesIn, secondsIn, dowIn)
|
|
if ((resultingHourDiff == SUMMERTIME_OFFSET and not (summerTime == true)) or (resultingHourDiff == WINTERTIME_OFFSET and not (summerTime == false))) then
|
|
print(yearIn .. "-" .. string.format("%0.2d", monthIn) .. "-" .. string.format("%0.2d", dayIn) .. " " .. string.format("%0.2d", hourIn) .. ":" .. string.format("%0.2d", minutesIn) .. ":" .. string.format("%0.2d", secondsIn) .. " (dow:" .. dowIn .. ") was not GMT+" .. resultingHourDiff .. " ( summer time was " .. tostring(summerTime) .. ")" )
|
|
os.exit(1)
|
|
else
|
|
print(yearIn .. "-" .. string.format("%0.2d", monthIn) .. "-" .. string.format("%0.2d", dayIn) .. " " .. string.format("%0.2d", hourIn) .. ":" .. string.format("%0.2d", minutesIn) .. ":" .. string.format("%0.2d", secondsIn) .. " summertime is " .. tostring(summerTime) .. " (GMT+" .. resultingHourDiff .. ")" )
|
|
end
|
|
end
|