diff --git a/lua/sca_main.lua b/lua/sca_main.lua index 09b0fcc..c1bb0b1 100644 --- a/lua/sca_main.lua +++ b/lua/sca_main.lua @@ -26,7 +26,7 @@ local function sca_setup_timezone() } while (daysPastUnixYear > 364) do - if (year % 4 == 0 && (year % 400 == 0 && year % 100 != 0)) then + if (year % 4 == 0 || (year % 400 == 0 && year % 100 != 0)) then daysPastUnixYear = daysPastUnixYear - 366 else daysPastUnixYear = daysPastUnixYear - 365 @@ -35,15 +35,15 @@ local function sca_setup_timezone() end for i = 0, 11, 1 do - if (daysPastUnixYear - daysPerMonth[i] >= daysPerMonth[i]) then - if (i == 2 && (year % 4 == 0 && (year % 400 == 0 && year % 100 != 0))) then + if (daysPastUnixYear - daysPerMonth[i] > daysPerMonth[i]) then + if (i == 2 && (year % 4 == 0 || (year % 400 == 0 && year % 100 != 0))) then daysPastUnixYear = daysPastUnixYear - (daysPerMonth[i] + 1) else daysPastUnixYear = daysPastUnixYear - daysPerMonth[i] end month = month + 1 else - day = daysPastUnixYear - 1 + day = daysPastUnixYear break end end @@ -53,15 +53,15 @@ local function sca_setup_timezone() if (month > 2 && month < 9) then summerTime = true elseif (month == 2) then - // If its less than 6 days until end of the month (aka last Weekday in the month) and its sunday and its 3 am or later.... - if ((daysPerMonth[month] - day <= 6) && weekDay == 3 && hoursInSeconds >= 7200) then + // If its less than 6 days until end of the month (aka last Weekday in the month) and its sunday and its 1 am UTC or later.... + if ((daysPerMonth[month] - day <= 7) && weekDay == 3 && hoursInSeconds >= 3600) then summerTime = true else summerTime = false end elseif (month == 9) then // The same action again but for winter time - if ((daysPerMonth[month] - day <= 6) && weekDay == 3 && hoursInSeconds >= 10800) then + if ((daysPerMonth[month] - day <= 7) && weekDay == 3 && hoursInSeconds >= 3600) then summerTime = false else summerTime = true