-
Notifications
You must be signed in to change notification settings - Fork 408
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrong calculation of night and nightEnd for polar night and very high altitudes. #70
Comments
Related to #45. See "Computing rise/set times" by Paul Schlyter , chapter 2. Currently unmerged patch to #45 may be used to solve this issue. |
I'm also seeing invalid dates being returned for night and nightEnd in Sheffield, UK. However I don't think this is necessarily a bug. The northern parts of the UK do get a sunrise and sunset every day, but for a week or two in the summer months we never actually reach true astronomical night. I would suggest returning something other than an invalid date in this case, such as false or null, but otherwise it's correct behaviour not to have a night and a nightEnd — at least for the north of the UK. Test lat/lng for Sheffield: 53.379979, -1.469407 — on July 28, 2016. Wikipedia has this: At latitudes greater than about 48.5 degrees North or South, on dates near the summer solstice, twilight can last from sunset to sunrise, since the Sun does not go more than 18 degrees below the horizon, so complete darkness does not occur even at midnight. These latitudes include many densely populated regions of the Earth, including the entire United Kingdom and other countries in northern Europe. |
I also ran into this issue. Instead of "Invalid Date" I guess it would be preferable to return boolean true in cases where there is no sunrise/sunset because the sun is always up or boolean false if there is no sunrise/sunset because the sun is always down . It's currently not possible to distinguish between the two cases. Same for the twilight phases. |
I'm also experiencing this issue for Surrey, BC SunCalc.getTimes(new Date(2017,5,21,12,0,0),49.1,-122.8) I thought this was wrong, but I guess not according to this page: I never knew we didn't have a night! |
London today, near midsummer - nightEnd and night both invalid dates
|
This is actually correct as the sun doesn't go below astronomical twilight this time of the year => thus no night phase. |
When latitude is 89.5 °C (almost the north pole), strange things happen with calling getTimes() for different dates.
console.log(SunCalc.getTimes(new Date(2016, 1, 1, 12, 0, 0), 89.5, 21));
will result in Invalid Date on night and nightEnd, which is correct because of the polar night.
console.log(SunCalc.getTimes(new Date(2016, 0, 31, 12, 0, 0), 89.5, 21));
will result in night: Sun Jan 31 2016 22:07:25 GMT+0100 (CET) and nightEnd: Sun Jan 31 2016 01:33:42 GMT+0100 (CET) which seems wrong. It should say Invalid Date, too on these properties.
The text was updated successfully, but these errors were encountered: