strptime 1.0.8 → 1.0.10
raw patch · 3 files changed
+27/−4 lines, 3 filesdep +text
Dependencies added: text
Files
- Data/Time/Parse.hsc +23/−0
- cbits/hstrptime.c +2/−2
- strptime.cabal +2/−2
Data/Time/Parse.hsc view
@@ -35,6 +35,10 @@ import qualified Data.ByteString.Internal as BI import qualified Data.ByteString.Lazy.Char8 as L import qualified Data.ByteString.Lazy.Internal as LI+import qualified Data.Text as T+import qualified Data.Text.Encoding as TE+import qualified Data.Text.Lazy as TL+import qualified Data.Text.Lazy.Encoding as TLE #include <time.h> #include "hstrptime.h"@@ -53,6 +57,7 @@ (t, n) <- ff s return (t, drop n s) where ff = strptime_ f+ instance Strptime L.ByteString where strptime f = \s -> do (t, n) <- ff s@@ -65,6 +70,18 @@ return (t, S.drop (fromIntegral n) s) where ff = strptime_ f +instance Strptime T.Text where+ strptime f = \s -> do+ (t, n) <- ff s+ return (t, T.drop (fromIntegral n) s)+ where ff = strptime_ f++instance Strptime TL.Text where+ strptime f = \s -> do+ (t, n) <- ff s+ return (t, TL.drop (fromIntegral n) s)+ where ff = strptime_ f+ class Strptime_ a where strptime_ :: a -> a -> Maybe (LocalTime, Int) @@ -73,6 +90,12 @@ instance Strptime_ L.ByteString where strptime_ f = let pf = S.concat (L.toChunks f) in \s -> strptime_ pf (S.concat . L.toChunks $ s)++instance Strptime_ T.Text where+ strptime_ f = let pf = TE.encodeUtf8 f in \s -> strptime_ pf (TE.encodeUtf8 s)++instance Strptime_ TL.Text where+ strptime_ f = let pf = TLE.encodeUtf8 f in \s -> strptime_ pf (TLE.encodeUtf8 s) instance Strptime_ S.ByteString where strptime_ f = U.unsafePerformIO $ do
cbits/hstrptime.c view
@@ -546,7 +546,7 @@ if (val % 100 >= 60) return NULL; val = (val / 100) * 100 + ((val % 100) * 50) / 30; }- if (val > 1200) return NULL;+ if ((neg && val > 1200) || (!neg && val > 1400)) return NULL; off = (val * 3600) / 100; if (neg) off = -off; *poffset = off;@@ -1068,7 +1068,7 @@ if (val % 100 >= 60) return NULL; val = (val / 100) * 100 + ((val % 100) * 50) / 30; }- if (val > 1200) return NULL;+ if ((neg && val > 1200) || (!neg && val > 1400)) return NULL; off = (val * 3600) / 100; if (neg) off = -off; *poffset = off;
strptime.cabal view
@@ -1,6 +1,6 @@ Name: strptime Category: System, Data, Parsing-Version: 1.0.8+Version: 1.0.10 Cabal-version: >= 1.2 Build-type: Simple Copyright: Eugene Kirpichov@@ -27,7 +27,7 @@ Flag split-base Library- Build-Depends: time, bytestring+ Build-Depends: time, bytestring, text C-sources: cbits/hstrptime.c GHC-Options: -O2 Include-dirs: include