Skip to content

Commit cec8b76

Browse files
BUG: corner case
1 parent 49fe6ea commit cec8b76

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

suntime/suntime.py

+9-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
1+
import calendar
22
import math
33
import datetime
44
from dateutil import tz
@@ -168,6 +168,14 @@ def _calc_sun_time(self, date, isRiseTime=True, zenith=90.8):
168168
if hr == 24:
169169
hr = 0
170170
day += 1
171+
172+
if day > calendar.monthrange(year, month)[1]:
173+
day = 1
174+
month += 1
175+
176+
if month > 12:
177+
month = 1
178+
year += 1
171179

172180
return datetime.datetime(year, month, day, hr, int(min), tzinfo=tz.tzutc())
173181

0 commit comments

Comments
 (0)