chrisblakley / Daylight-Calendar-ICS

Daylight Calendar is a dynamically generated .ics calendar that you can host and subscribe to in Google Calendar, iCal, or other calendar software.
https://gearside.com/google-daylight-calendar/
GNU General Public License v2.0
43 stars 6 forks source link

Bug in GMT data? #9

Closed Rose-emma closed 1 year ago

Rose-emma commented 1 year ago

Screenshot_20230319-084049 Hey, first of all love this calendar feature! This was exactly what I was looking for.

Then to the bug(?): I had some trouble getting the correct sunlight times. I live in GMT +1 (Amsterdam), but when I filled in 1 or +1 the wrong sunlight showed up in my calendar (the blue ones in the screenshot). The sunlight window was correct when I used: https://gearside.com/calendars/daylight.php?lat=52.4&lng=4.9&gmt=-4 (Orange in the screenshot)

Only the solar noon time seems still off. Should be around 1 or 2 PM. Is this a bug or did I maybe not use the correct query parameters?

Rose-emma commented 1 year ago

Oh one addition, for the sun.php query I do get the right results with gmt=1

chrisblakley commented 1 year ago

Thanks for the info. When I first created this I wrote all of the code specifically for my own timezone and then the GMT offsets was admittedly an afterthought, so there certainly could be bugs related to that.

The other thing that is difficult is that the latitude and longitude data is only used for the sun timings, but not the actual timezone, so DST could make things a little weird– I don't think that is happening here, but worth noting.

I made a small adjustment just now that may help, but it is somewhat difficult to test, so I suppose we can wait until tomorrow to see if anything changes favorably.

This started as a personal project but I do know that a small amount of people have started using it, so what I should do is re-write the code to account for all of that from the start. However, I'm not sure if/when I'd be able to get to that. Until then, anyone who finds this and has time to diagnose issues like this is welcome to make pull requests.

chrisblakley commented 1 year ago

Okay, I actually took another look at this and made a few major changes. Passing a gmt= parameter in the URL should be more accurate now, however, the new and improved way to call this would be to give it your actual timezone itself like this:

https://gearside.com/calendars/daylight.php?lat=43.1234&lng=-76.1234&timezone=America/New_York

You can find the timezone text to use here: https://www.php.net/manual/en/timezones.php

Still a little tough to test this, but I'm optimistic this will do a much better job for everyone. I'll leave this issue open until we're satisfied it is resolved.

chrisblakley commented 1 year ago

Noticed a minor issue related to my edits this morning and have resolved that. It seems to be working entirely correct now so fingers crossed you'll see it accurate in your timezone as well. If it is still way off, check back for the next time Google updates it, or delete the calendar and re-add it (with a cache-busting query string like ...daylight.php?sdfgsdfgadsf).

Rose-emma commented 1 year ago

Oke sorry for the late reply, and thank you for the quick fixing, because the noon time is now correct!

chrisblakley commented 1 year ago

Great to hear– thanks for confirming!