Sunrise, sunset times are off by 4 hours (UTC versus local time) #222
-
First time using the library. Using riseset.c as a guide, Im getting sunrise too early and sunsets too late. Are there config settings I need to set up ? What test case would you suggest ? Im comparing output to https://www.timeanddate.com eg
produces : whereas the website lists both correctly 4 hors earlier : sunrise at 05.19 and sunset at 8.03 Appreciate pointers. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 7 replies
-
Hi @achalmers and welcome to the project! Your code looks great, and everything is working correctly. The 4 hour discrepancy is because the times are reported in UTC, not local time. Astronomy Engine does not know anything about time zones. It does everything in UTC. It turns out time zones are extremely complicated: the boundary lines are complicated and the rules change frequently at the whim of governments around the world. I decided early on that time zone support is out of scope for Astronomy Engine. Usually you can use your operating system (C/C++, Python), browser (JavaScript), or language runtime (C#) to convert to local time. For example, in the linux_riseset.c demo, you can see an example of where I use the Linux function Also, if you can add a couple more decimal places of accuracy to your longitude and latitude, the predictions should match timeanddate.com within a minute or two. That is great that you are running this in an Arduino environment! I am a big fan of Arduino and Raspberry Pi. How much RAM does your system have? I ask because I wondered whether the Astronomy Engine C code would fit in a microcontroller system. |
Beta Was this translation helpful? Give feedback.
-
orrery_TTGO.mp4 |
Beta Was this translation helpful? Give feedback.
Hi @achalmers and welcome to the project! Your code looks great, and everything is working correctly. The 4 hour discrepancy is because the times are reported in UTC, not local time. Astronomy Engine does not know anything about time zones. It does everything in UTC. It turns out time zones are extremely complicated: the boundary lines are complicated and the rules change frequently at the whim of governments around the world. I decided early on that time zone support is out of scope for Astronomy Engine.
Usually you can use your operating system (C/C++, Python), browser (JavaScript), or language runtime (C#) to convert to local time. For example, in the linux_riseset.c demo, you can see …