]> git.sven.stormbind.net Git - sven/scripts.git/commitdiff
Fix exit code for location-date combinations without sunrise/sunset.
authorSven Hoexter <sven@stormbind.net>
Thu, 3 Feb 2022 20:23:54 +0000 (21:23 +0100)
committerSven Hoexter <sven@stormbind.net>
Thu, 3 Feb 2022 20:23:54 +0000 (21:23 +0100)
weblogpro/suntime.lua

index fc651660bf841df587c5647ebd437dc0979c2f3b..9e46a0bead0b5ed0858ad998db952bab6ad10571 100755 (executable)
@@ -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