@@ -34,16 +34,21 @@ import Data.Time.Clock (UTCTime(..))
3434import qualified Data.Aeson.Types.Internal as Aeson
3535import qualified Data.Text as T
3636import qualified Data.Time.LocalTime as Local
37−#if !MIN_VERSION_base(4,7,0)
38−import Unsafe.Coerce
3937
40−mkPico :: Integer -> Pico
41−mkPico = unsafeCoerce
42−#else
38+#if MIN_VERSION_base(4,7,0)
39+
4340import Data.Fixed (Fixed(MkFixed))
4441
4542mkPico :: Integer -> Pico
4643mkPico = MkFixed
44+
45+#else
46+
47+import Unsafe.Coerce
48+
49+mkPico :: Integer -> Pico
50+mkPico = unsafeCoerce
51+
4752#endif
4853
4954-- | Run an attoparsec parser as an aeson parser.
@@ -91,13 +96,12 @@ seconds = do
9196 t <- anyChar *> takeWhile1 isDigit
9297 return $! parsePicos real t
9398 _ -> return $! fromIntegral real
94−
95−parsePicos :: Int -> T.Text -> Pico
96−parsePicos a0 t = mkPico (fromIntegral (t' * 10^n))
97− where T n t' = T.foldl' step (T 12 (fromIntegral a0)) t
98− step ma@(T m a) c
99− | m <= 0 = ma
100− | otherwise = T (m-1) (10 * a + fromIntegral (ord c) .&. 15)
99+ where
100+ parsePicos a0 t = mkPico (fromIntegral (t' * 10^n))
101+ where T n t' = T.foldl' step (T 12 (fromIntegral a0)) t
102+ step ma@(T m a) c
103+ | m <= 0 = ma
104+ | otherwise = T (m-1) (10 * a + fromIntegral (ord c) .&. 15)
101105
102106-- | Parse a time zone, and return 'Nothing' if the offset from UTC is
103107-- zero. (This makes some speedups possible.)