In this case, I don’t use dateTime… I use a time variable
. (set by another piston)
IE:
time @sunrise 6:47:19 AM
time @sunset 7:12:47 PM
but the key element to this whole piston is converting (sunset - sunrise) into seconds.
(we need to know how many seconds the sun is above the horizon… Snippet below)
That is correct. All of the math is within a single day.
(which is automatically compared to your yearly expectations)
Here is a tiny snippet referring to my @global:
{cur} is a string, and {secNow} is an integer…
For example, 7:03:06pm - 6am = 13:03:06
then we want (6) + (3 * 60) + (13 * 3600) = 46,986 seconds of sunlight
That is an acceptable level of margin using floor rounded minutes.
Mine is now within 0.04% accuracy using the seconds of sunrise and sunset.
Remember, this @dlp percent only changes once a day…
You can run it at 1am, noon and 11pm, and the daily numbers will all be the same.