From e2af5ba8f56fe08589c624c6f010ed48681e79c4 Mon Sep 17 00:00:00 2001 From: ollo Date: Tue, 12 Apr 2016 21:02:56 +0200 Subject: [PATCH] All Tests are finished --- timecore.lua | 14 ++++++++++++-- unit/timetest.lua | 4 ++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/timecore.lua b/timecore.lua index f3124d3..59772bf 100644 --- a/timecore.lua +++ b/timecore.lua @@ -25,8 +25,18 @@ function getLocalTime(year, month, day, hour, minutes, seconds,dow) -- we are in 100% in the summer time if (month > 3 and month < 10) then hour = hour + 1 - -- October is not 100% Summer time - --FIXME elseif (month == 10 and + -- March is not 100% Summer time, only starting at the last sunday + elseif ((month == 3 and day >= 25 and day <= 31 and hour > 2 and dow == 7) or + -- Only handle days after the last sunday in this month + ((month == 3 and day >= 25 and day <= 31 and dow < 7 and ((7-dow + day) > 31))) ) then + hour = hour + 1 + -- October is not 100% Summer time, ending with the last sunday + elseif ((month == 10 and day >= 25 and day <= 31 and hour < 2 and dow == 7) or + (month == 10 and day >= 25 and day <= 31 and dow < 7 and ((7-dow + day) <= 31)) or + -- Handle all days up to the 25. of october + (month == 10 and day < 25 ) + )then + hour = hour + 1 end return year, month, day, hour, minutes, seconds diff --git a/unit/timetest.lua b/unit/timetest.lua index 9a1a2c7..7db9347 100644 --- a/unit/timetest.lua +++ b/unit/timetest.lua @@ -3,10 +3,10 @@ dofile("../timecore.lua") function checkTime(yearIn, monthIn, dayIn, hourIn, minutesIn, secondsIn,dowIn, resultingHourDiff) - year, month, day, hour, minutes, seconds = getLocalTime(yearIn, monthIn, dayIn, hourIn, minutesIn, secondsIn,dow) + year, month, day, hour, minutes, seconds = getLocalTime(yearIn, monthIn, dayIn, hourIn, minutesIn, secondsIn, dowIn) if not (year == yearIn and monthIn == month and day == dayIn and hour == (hourIn + resultingHourDiff) and minutesIn == minutes and secondsIn == seconds ) 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) .. " not as expected GMT+" .. resultingHourDiff .. " but GMT+" .. (hour - hourIn) ) + 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) .. " (" .. dowIn .. ".th dayOfWeek) not as expected GMT+" .. resultingHourDiff .. " but GMT+" .. (hour - hourIn) ) 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) .. " is GMT+" .. resultingHourDiff )