**kysko** » June 22nd, 2019, 12:51 am

yes, I've been reviewing many algorithms for equation of time, declination, sunrise, sunset, etc, didn't want to fetch data.

I've already implemented a simple one in pure rainmeter code, accurate enough for daily needs.

I had seen your code; I thought I saw an implementation error for getting the julian days since jd2000, but I might be mistaken.

You see, when I use a lua 5.1.5 command line, print(1/3) gives me 0.3333... and print(4/3) gives 1.3333..., so I thought lua didn't have integer division.

Usually the algorithm you (seem to) use is for integer division, so with math.floor in lua.

In fact, a quick check shows that not using the floor function doesn't give a big error after all!

To be sure, such a function should give 0 for (y,m,d,h)=(2000,1,1,12); yours gives -0.9, while using math.floor it gives 0 as expected.

For (y,m,d,h)=(2019,6,21,12), your function gives 7110.896..., while using math.floor we get 7111.0, which is quite close!

I had never thought to compare the error given by not using integer division... now I see it!

But then again... (2019.5 - 2000)*365.24 - 10 days left in june = 7112.18, which isn't bad either if you don't care about astronomic-wise precision!

Anyway, I learn a lot by inspecting skins such as yours and many others, thanks.