def seconds_and_nanoseconds(dt): if isinstance(dt, datetime): dt = DateTime.from_native(dt) zone_epoch = DateTime(1970, 1, 1, tzinfo=dt.tzinfo) t = dt.to_clock_time() - zone_epoch.to_clock_time() return t.seconds, t.nanoseconds
def test_conversion_to_t(self): dt = DateTime(2018, 4, 26, 23, 0, 17.914390409) t = dt.to_clock_time() self.assertEqual(t, ClockTime(63660380417, 914390409))