From af9948e0432b93a4c18c6318dff4ce25b00f0991 Mon Sep 17 00:00:00 2001 From: joe Date: Fri, 9 May 2014 20:29:30 -0400 Subject: dateParser --- TimeUtil.hs | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/TimeUtil.hs b/TimeUtil.hs index a4391e9..77e85bf 100644 --- a/TimeUtil.hs +++ b/TimeUtil.hs @@ -17,6 +17,9 @@ import Control.Applicative import Data.Maybe import Data.Char import qualified Data.ByteString.Char8 as S +import qualified Data.ByteString.Lazy.Char8 as L + +import ScanningParser class IsTime a where fromZonedTime :: ZonedTime -> a @@ -76,6 +79,16 @@ parseRFC2822 str = now :: IO Integer now = floor <$> Data.Time.Clock.POSIX.getPOSIXTime +dateParser :: ScanningParser L.ByteString UTCTime +dateParser = ScanningParser ffst pbdy + where + ffst bs = do + let (h,bs') = L.splitAt 6 bs + if h=="Date: " + then return $ parseRFC2822 $ L.toStrict bs' + else Nothing + pbdy date xs = (date,xs) + {- main = do nowtime <- now -- cgit v1.2.3