Calculate Sunset and Sunrise Time on Fezzer

Quoting Joe_The_FEZ

[quote]Wouter Huysentruit … I cannot find any other way to contact you.

Sorry …
But on your Fezzer Sunrise/Sunset calculation there are problems:

#1. The source code on download is lock-out eg classes are greyed out.
#2. The sunrise and sunset times are reversed. It is not the print statement in your example but comes from the source code greyed out.
#3. The sunrise if off by 8 minutes and the sunset time is off by 11 minutes by using several on-line web-based sunrise/sunset calculators.


Don’t know what you mean with ‘greyed out’ in point #1. I’ve downloaded the code from fezzer and tried it in a new project (Windows Console, just replaced the MathEx with Math to run it on my PC instead of the FEZ, which is doing some other work now).

I’ve ran the example (set the date to DateTime.Now) and the debug output is:

Requested sunrise/sunset times for 27-02-11 10:23:54
The sun will rise at 07:38
The sun will set at 18:24

To me, these times are not reversed.
What’s more: I’ve tried the online calculation at Sunrise Sunset Calculator. Timezones, Daylight Savings Time, Longitude, Latitude.

And that resulted in:
Sunrise at 07:36:46
Sunset at 18:24:39

Which to me seems close enough :slight_smile:

Of course there are different implementations and if you look at the source of the SunTime class you’ll see many constants that are rounded to 3 digits after the decimal point.

But a difference of 3 minutes (or even 8 or 11) isn’t really a big deal as long as you don’t use it in a NASA project.

BTW I use this class to control the blinds at my house.