From e5af376ebc0a431d0e0e96cc300cdcf4ac7ec221 Mon Sep 17 00:00:00 2001 From: Brandon Rhodes Date: Thu, 17 Sep 2020 08:17:12 -0400 Subject: [PATCH] Inline private function _utc_to_tai() Now that it only has one use, its logic can live in the class. Another step towards #450. --- skyfield/timelib.py | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/skyfield/timelib.py b/skyfield/timelib.py index 33c008106..ef60f48f1 100644 --- a/skyfield/timelib.py +++ b/skyfield/timelib.py @@ -137,11 +137,19 @@ def utc(self, year, month=1, day=1, hour=0, minute=0, second=0.0): if hasattr(year, '__len__') and isinstance(year[0], datetime): return self.from_datetimes(year) - tai1, tai2 = _utc_to_tai( - self.leap_dates, self.leap_offsets, _to_array(year), - _to_array(month), _to_array(day), _to_array(hour), - _to_array(minute), _to_array(second), - ) + year = _to_array(year) + month = _to_array(month) + day = _to_array(day) + hour = _to_array(hour) + minute = _to_array(minute) + second = _to_array(second) + + j = julian_day(year, month, day) - 0.5 + i = searchsorted(self.leap_dates, j, 'right') + seconds = self.leap_offsets[i] + second + minute * 60.0 + hour * 3600.0 + j, seconds = _reconcile(j, seconds) + tai1, tai2 = j, seconds / DAY_S + t = Time(self, tai1, tai2 + tt_minus_tai) t.tai_fraction = tai2 return t @@ -1019,14 +1027,6 @@ def _datetime_to_utc_tuple(dt): return (dt.year, dt.month, dt.day, dt.hour, dt.minute, dt.second + dt.microsecond / 1e6) -def _utc_to_tai(leap_dates, leap_offsets, - year, month, day, hour, minute, second): - j = julian_day(year, month, day) - 0.5 - i = searchsorted(leap_dates, j, 'right') - seconds = leap_offsets[i] + second + minute * 60.0 + hour * 3600.0 - j, seconds = _reconcile(j, seconds) - return j, seconds / DAY_S - _JulianDate_deprecation_message = """Skyfield no longer supports direct\ instantiation of JulianDate objects (which are now called Time objects)