Evening time calculations fail for greater longitudes.
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
astral |
Fix Released
|
Medium
|
Simon Kennedy |
Bug Description
import datetime
from astral import Astral
date = datetime.
a = Astral()
a.sunset_
Traceback (most recent call last):
File "<input>", line 1, in <module>
File "/usr/lib/
sunset = datetime.
ValueError: hour must be in 0..23
The problem is that in the functions xxx_utc, the hours being given to the datetime.datetime constructor have been increased by longitude to more than 23.
This is easily fixed by adding these lines just before the datetime.datetime in each of those functions:
if hour > 23:
hour -= 24
date += datetime.
New version 0.2 added to PyPi