git.iko.soy/typeable/postgresql-simple
on master help sign in
Fix Time Parser tweaks
commit0453f2c7ef89b71ddcd8b4f974c43d760754ea04 authorLeon P Smith <leon@melding-monads.com> dateFri 18 Sep 2015, 15:52 (11 years ago) parent81bf589
1 file changed+4−3
src/Database/PostgreSQL/Simple/Time/Parser.hs+4−3
src/Database/PostgreSQL/Simple/Time/Parser.hs+4−3
@@ -72,12 +72,13 @@ seconds = do
7272 case mc of
7373 Just '.' -> do
7474 t <- anyChar *> takeWhile1 isDigit
75− return $! parsePicos real t
75+ return $! parsePicos (fromIntegral real) t
7676 _ -> return $! fromIntegral real
7777 where
78+ parsePicos :: Int64 -> B8.ByteString -> Pico
7879 parsePicos a0 t = toPico (fromIntegral (t' * 10^n))
79− where n = 12 - B8.length t
80− t' = B8.foldl' (\a c -> 10 * a + fromIntegral (ord c) .&. 15) a0
80+ where n = max 0 (12 - B8.length t)
81+ t' = B8.foldl' (\a c -> 10 * a + fromIntegral (ord c .&. 15)) a0
8182 (B8.take 12 t)
8283
8384-- | Parse a time zone, and return 'Nothing' if the offset from UTC is