MarcusOtter / APOD.Net

An unofficial .NET wrapper for NASA's Astronomy Picture of the Day API.
https://marcusotter.github.io/APOD.Net/
MIT License
9 stars 2 forks source link

Time zone errors #2

Closed MarcusOtter closed 4 years ago

MarcusOtter commented 4 years ago

The API has issues with handling time zones correctly.

If your local time is ahead of UTC, if you try and access the APOD for today's date just after midnight, the API will say that it's out of range (which makes sense, because for the API's local time it's not a new day yet).

If UTC is after 00:00 but the API time zone is not, you will get an internal service error, likely because the source code uses UTC so it's a valid request, but there's no content there until it's a new day for the local time.

The local time of the API is Eastern Time (UTC-4 or UTC-5) which is either Eastern Standard Time (EST) or Eastern Daylight Time (EDT) depending on daylight saving.

My wrapper needs to convert the local time zone to the current Eastern Time (EST or EDT) and then validate the requests after that. There should be unit tests testing multiple "local" time zones. This also means I can no longer use DateTime.Today, but instead have to use DateTime.Now since the time of day is important.