X-Git-Url: https://git.sven.stormbind.net/?p=sven%2Fscripts.git;a=blobdiff_plain;f=weblogpro%2Fsuntime.lua;fp=weblogpro%2Fsuntime.lua;h=9e46a0bead0b5ed0858ad998db952bab6ad10571;hp=fc651660bf841df587c5647ebd437dc0979c2f3b;hb=9dd895ef2d84cad05cb7c53fd56e34619dfcead6;hpb=8efa31c1cd9df5d6428a36abcf7a96cf175020a8 diff --git a/weblogpro/suntime.lua b/weblogpro/suntime.lua index fc65166..9e46a0b 100755 --- a/weblogpro/suntime.lua +++ b/weblogpro/suntime.lua @@ -58,7 +58,7 @@ function daysInMonth(year, month) end --[[ Ported from https://pypi.org/project/suntime/ - which is based on https://stackoverflow.com/questions/19615350/calculate-sunrise-and-sunset-times-for-a-given-gps-coordinate-within-postgresql + which is based on https://stackoverflow.com/questions/19615350/ which took the algorithm from https://web.archive.org/web/20161022214335/https://williams.best.vwh.net/sunrise_sunset_algorithm.htm year: number @@ -118,11 +118,11 @@ function calc_sun_time(year, month, day, lon, lat, getRiseTime) if(cosH > 1) then -- return None -- The sun never rises on this location (on the specified date) print("Sun will never rise here and now.") - os.exit() + os.exit(1) elseif(cosH < -1) then -- return None -- The sun never sets on this location (on the specified date) print("Sun will never rise here and now.") - os.exit() + os.exit(0) end -- 7b. finish calculating H and convert into hours