#POINT - improved IsDay() for Kola

This commit is contained in:
Applevangelist 2025-05-21 10:21:48 +02:00
parent 997baf21a0
commit a4feafab8e
2 changed files with 11 additions and 4 deletions

View File

@ -2992,8 +2992,10 @@ do -- COORDINATE
local sunrise=UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, true, Tdiff)
local sunset=UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, false, Tdiff)
if sunrise == "N/R" then return false end
if sunrise == "N/S" then return true end
if type(sunrise) == "string" or type(sunset) == "string" then
if sunrise == "N/R" then return false end
if sunset == "N/S" then return true end
end
local time=UTILS.ClockToSeconds(clock)
@ -3011,6 +3013,11 @@ do -- COORDINATE
-- Todays sun set in sec.
local sunset=self:GetSunset(true)
if type(sunrise) == "string" or type(sunset) == "string" then
if sunrise == "N/R" then return false end
if sunset == "N/S" then return true end
end
-- Seconds passed since midnight.
local time=UTILS.SecondsOfToday()

View File

@ -2145,9 +2145,9 @@ function UTILS.GetSunRiseAndSet(DayOfYear, Latitude, Longitude, Rising, Tlocal)
local cosH = (cos(zenith) - (sinDec * sin(latitude))) / (cosDec * cos(latitude))
if rising and cosH > 1 then
return "N/S" -- The sun never rises on this location on the specified date
return "N/R" -- The sun never rises on this location on the specified date
elseif cosH < -1 then
return "N/R" -- The sun never sets on this location on the specified date
return "N/S" -- The sun never sets on this location on the specified date
end
-- Finish calculating H and convert into hours