@@ -34,16 +34,21 @@ import Data.Time.Clock (UTCTime(..))
34import qualified Data.Aeson.Types.Internal as Aeson
34import qualified Data.Aeson.Types.Internal as Aeson
35import qualified Data.Text as T
35import qualified Data.Text as T
36import qualified Data.Time.LocalTime as Local
36import qualified Data.Time.LocalTime as Local
37−#if !MIN_VERSION_base(4,7,0)
40−mkPico :: Integer -> Pico
38+#if MIN_VERSION_base(4,7,0)
41−mkPico = unsafeCoerce
39+
43import Data.Fixed (Fixed(MkFixed))
40import Data.Fixed (Fixed(MkFixed))
45mkPico :: Integer -> Pico
42mkPico :: Integer -> Pico
46mkPico = MkFixed
43mkPico = MkFixed
49+mkPico :: Integer -> Pico
49-- | Run an attoparsec parser as an aeson parser.
54-- | Run an attoparsec parser as an aeson parser.
@@ -91,13 +96,12 @@ seconds = do
91 t <- anyChar *> takeWhile1 isDigit
96 t <- anyChar *> takeWhile1 isDigit
92 return $! parsePicos real t
97 return $! parsePicos real t
93 _ -> return $! fromIntegral real
98 _ -> return $! fromIntegral real
95−parsePicos :: Int -> T.Text -> Pico
96−parsePicos a0 t = mkPico (fromIntegral (t' * 10^n))
100+ parsePicos a0 t = mkPico (fromIntegral (t' * 10^n))
97− where T n t' = T.foldl' step (T 12 (fromIntegral a0)) t
101+ where T n t' = T.foldl' step (T 12 (fromIntegral a0)) t
98− step ma@(T m a) c
102+ step ma@(T m a) c
99− | m <= 0 = ma
103+ | m <= 0 = ma
100− | otherwise = T (m-1) (10 * a + fromIntegral (ord c) .&. 15)
104+ | otherwise = T (m-1) (10 * a + fromIntegral (ord c) .&. 15)
102-- | Parse a time zone, and return 'Nothing' if the offset from UTC is
106-- | Parse a time zone, and return 'Nothing' if the offset from UTC is
103-- zero. (This makes some speedups possible.)
107-- zero. (This makes some speedups possible.)