Skip to content

Commit

Permalink
bug #44 - Fix for our antipodean friends.
Browse files Browse the repository at this point in the history
  • Loading branch information
sffjunkie committed Feb 11, 2020
1 parent 60aa65f commit 11b3a22
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 3 deletions.
3 changes: 0 additions & 3 deletions src/astral/sun.py
Expand Up @@ -376,9 +376,6 @@ def time_of_transit(
timeDiff = 4.0 * delta
timeUTC = 720 + timeDiff - eq_of_time(t)

if timeUTC < 0:
raise ValueError(f"Sun never transits at a zenith of {zenith} on {date}")

td = minutes_to_timedelta(timeUTC)
dt = datetime.datetime(date.year, date.month, date.day) + td
dt = pytz.utc.localize(dt) # pylint: disable=E1120
Expand Down
17 changes: 17 additions & 0 deletions src/test/test_wellington.py
@@ -0,0 +1,17 @@
import datetime

import pytz
from astral.geocoder import database, lookup
from astral.sun import sun

from almost_equal import datetime_almost_equal


def test_Wellington():
wellington = lookup("Wellington", database())
dt = datetime.date(2020, 2, 11)
tz = pytz.timezone(wellington.timezone)
s = sun(wellington.observer, dt, tzinfo=tz)
assert datetime_almost_equal(
s["sunrise"], tz.localize(datetime.datetime(2020, 2, 11, 6, 38, 42))
)

0 comments on commit 11b3a22

Please sign in to comment.