'Issue with Python Sun get_sunset_time() routine

I don't think this is normal

today_sr = sun.get_sunrise_time()
today_ss = sun.get_sunset_time()
today_sr < today_ss
False

today_sr is datetime.datetime(2022, 5, 2, 9, 50, tzinfo=tzutc()) today_ss is datetime.datetime(2022, 5, 2, 0, 10, tzinfo=tzutc())

today_ss should be 2022, 5, 3 if it's going to cross over midnight in UTC time.

Is there something I'm doing wrong?



Solution 1:[1]

Samwise got me pointed in the right direction. It's a bug in the routine I'm using

https://github.com/SatAgro/suntime/issues/13

It's been lingering since 2020 so I've fixed it by doing this in my code

if today_sr > today_ss:
    today_ss = today_ss + timedelta(days=1)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1