@@ -21,6 +21,7 @@ import Prelude.Compat
2121
2222import Data.Int (Int64)
2323import Data.Time
24+import Data.Time.Clock (diffTimeToPicoseconds)
2425import Unsafe.Coerce (unsafeCoerce)
2526
2627#if MIN_VERSION_base(4,7,0)
@@ -55,11 +56,11 @@ posixDayLength = fromInteger 86400
5556
5657diffTimeOfDay64 :: DiffTime -> TimeOfDay64
5758diffTimeOfDay64 t
58− | t >= posixDayLength = TOD 23 59 (60000000000000 + (unsafeCoerce (t - posixDayLength)))
59+ | t >= posixDayLength = TOD 23 59 (60000000000000 + pico (t - posixDayLength))
5960 | otherwise = TOD (fromIntegral h) (fromIntegral m) s
60− where (h,mp) = fromIntegral pico `quotRem` 3600000000000000
61+ where (h,mp) = pico t `quotRem` 3600000000000000
6162 (m,s) = mp `quotRem` 60000000000000
62− pico = unsafeCoerce t :: Integer
63+ pico = fromIntegral . diffTimeToPicoseconds
6364
6465toTimeOfDay64 :: TimeOfDay -> TimeOfDay64
6566toTimeOfDay64 (TimeOfDay h m s) = TOD h m (fromIntegral (fromPico s))