diff --git a/python/lsst/daf/butler/time_utils.py b/python/lsst/daf/butler/time_utils.py index ed3eb966e3..5e003c72e5 100644 --- a/python/lsst/daf/butler/time_utils.py +++ b/python/lsst/daf/butler/time_utils.py @@ -112,8 +112,10 @@ def astropy_to_nsec(self, astropy_time: astropy.time.Time) -> int: delta = value - self.epoch # Special care needed to preserve nanosecond precision. # Usually jd1 has no fractional part but just in case. - jd1, extra_jd2 = divmod(delta.jd1, 1) - value = int(jd1) * self._NSEC_PER_DAY + int(round((delta.jd2 + extra_jd2) * self._NSEC_PER_DAY)) + # Can use "internal" ._time.jd1 interface because we know that both + # are TAI. This is a few percent faster than using .jd1. + jd1, extra_jd2 = divmod(delta._time.jd1, 1) + value = int(jd1) * self._NSEC_PER_DAY + int(round((delta._time.jd2 + extra_jd2) * self._NSEC_PER_DAY)) return value def nsec_to_astropy(self, time_nsec: int) -> astropy.time.Time: