strptime 0.1.2 → 0.1.3
raw patch · 2 files changed
+8/−8 lines, 2 files
Files
- Data/Time/Parse.hsc +7/−7
- strptime.cabal +1/−1
Data/Time/Parse.hsc view
@@ -34,7 +34,7 @@ -- | The class of values from which time may be parsed class Strptime a where- -- | Given a format string in the format of C's strptime (see <http://linux.die.net/man/3/strptime>) + -- | Given a format string in the format of C's strptime (see <http://linux.die.net/man/3/strptime>) -- and a data string, parse a date+time value from the data string and also return the remainder -- of the data string. strptime :: a -> a -> Maybe (LocalTime, a)@@ -43,18 +43,18 @@ strptime f = \s -> do (t, n) <- ff s return (t, drop n s)- where ff = strptime_ f + where ff = strptime_ f instance Strptime L.ByteString where strptime f = \s -> do (t, n) <- ff s return (t, L.drop (fromIntegral n) s)- where ff = strptime_ f + where ff = strptime_ f instance Strptime S.ByteString where strptime f = \s -> do (t, n) <- ff s return (t, S.drop (fromIntegral n) s)- where ff = strptime_ f + where ff = strptime_ f class Strptime_ a where strptime_ :: a -> a -> Maybe (LocalTime, Int)@@ -78,7 +78,7 @@ return $ \s -> unsafePerformIO $ S.useAsCString s $ \cs -> do allocaBytes (#const sizeof(struct tm)) $ \p_tm -> do last <- strptime_c cs (castPtr ztf) p_tm- if last == nullPtr + if last == nullPtr then return Nothing else do sec <- (#peek struct tm,tm_sec ) p_tm :: IO CInt@@ -87,9 +87,9 @@ mday <- (#peek struct tm,tm_mday ) p_tm :: IO CInt month <- (#peek struct tm,tm_mon ) p_tm :: IO CInt year <- (#peek struct tm,tm_year ) p_tm :: IO CInt- let day = fromGregorian (fromIntegral (year+1900)) (fromIntegral month) (fromIntegral mday)+ let day = fromGregorian (fromIntegral (year+1900)) (1+fromIntegral month) (fromIntegral mday) let tod = TimeOfDay (fromIntegral hour) (fromIntegral min) (fromIntegral sec)- + return $ Just (LocalTime day tod, last `minusPtr` cs) type CTm = () -- struct tm
strptime.cabal view
@@ -1,6 +1,6 @@ Name: strptime Category: System, Data, Parsing-Version: 0.1.2+Version: 0.1.3 Cabal-version: >= 1.2 Build-type: Simple Copyright: Eugene Kirpichov