@@ -50,11 +50,16 @@ data TimeOfDay64 = TOD {-# UNPACK #-} !Int
5050 {-# UNPACK #-} !Int
5151 {-# UNPACK #-} !Int64
5252
53+posixDayLength :: DiffTime
54+posixDayLength = fromInteger 86400
55+
5356diffTimeOfDay64 :: DiffTime -> TimeOfDay64
54−diffTimeOfDay64 t = TOD (fromIntegral h) (fromIntegral m) s
55− where (h,mp) = fromIntegral pico `quotRem` 3600000000000000
56− (m,s) = mp `quotRem` 60000000000000
57− pico = unsafeCoerce t :: Integer
57+diffTimeOfDay64 t
58+ | t >= posixDayLength = TOD 23 59 (60000000000000 + (unsafeCoerce (t - posixDayLength)))
59+ | otherwise = TOD (fromIntegral h) (fromIntegral m) s
60+ where (h,mp) = fromIntegral pico `quotRem` 3600000000000000
61+ (m,s) = mp `quotRem` 60000000000000
62+ pico = unsafeCoerce t :: Integer
5863
5964toTimeOfDay64 :: TimeOfDay -> TimeOfDay64
6065toTimeOfDay64 (TimeOfDay h m s) = TOD h m (fromIntegral (fromPico s))