packages feed

parsedate 2006.6.4 → 2006.11.10

raw patch · 3 files changed

+9/−42 lines, 3 filesnew-uploader

Files

System/Time/Parse.hs view
@@ -144,7 +144,6 @@  -- FIXME: verify input -- FIXME: years outside 1000-9999 probably don't work--- FIXME: what about extra whitespace in input? -- FIXME: set ctYDay -- FIXME: set ctIsDST -- FIXME: missing formats from GNU date(1):@@ -168,6 +167,7 @@     -- FIXME: implement     doFmt ('%':'_':cs) = doFmt ('%':cs)     doFmt ('%':c:cs) = decode c >> doFmt cs+    doFmt (c:cs) | isSpace c = whitespace >> doFmt cs     doFmt (c:cs) = char c >> doFmt cs     doFmt "" = return ()     @@ -189,8 +189,8 @@     decode 'l' = read2 >>= setHour12     decode 'm' = read2 >>= \mon -> setMonth (toEnum (mon-1))     decode 'M' = read2 >>= setMin-    -- FIXME: strptime(3) accepts "arbitrary whitespace" for %n-    decode 'n' = char '\n' >> return ()+    -- strptime(3) accepts "arbitrary whitespace" for %n+    decode 'n' = whitespace >> return ()     decode 'p' = do 		 x <- (string am >> return 0) <|> (string pm >> return 12) 		 updateHour (\h -> x + h `rem` 12)@@ -216,7 +216,7 @@     decode 'X' = doFmt (timeFmt l)     -- FIXME: should probably be zero padded,      --        need to change formatCalendarTime too-    decode 'Y' = int >>= setYear+    decode 'Y' = readN 4 >>= setYear     -- FIXME: maybe 04 should be 2004, not 1904?     decode 'y' = read2 >>= \c -> updateYear (\y -> (y `quot` 100) * 100 + c)     -- FIXME: are timezone names always [A-Z]+ ?@@ -290,3 +290,7 @@  sign :: CharParser st Int sign = (char '+' >> return 1) <|> (char '-' >> return (-1))++-- | Matches zero or more whitespace characters.+whitespace :: CharParser st String+whitespace = many (satisfy isSpace)
− examples/Parsec.hs
@@ -1,37 +0,0 @@-import System.Locale-import System.Time-import System.Time.Parse-import Text.ParserCombinators.Parsec--iso8601DateTimeFormat :: String-iso8601DateTimeFormat = "%Y-%m-%d %H:%M:%S"--parseISO8601DateTime :: Parser CalendarTime-parseISO8601DateTime = -    parsecCalendarTime defaultTimeLocale iso8601DateTimeFormat--showISO8601DateTime :: CalendarTime -> String-showISO8601DateTime = -    formatCalendarTime defaultTimeLocale iso8601DateTimeFormat--parseEmptyDate :: Parser CalendarTime-parseEmptyDate = parsecCalendarTime defaultTimeLocale ""--timeNow :: IO CalendarTime-timeNow = getClockTime >>= toCalendarTime--p :: Parser a -> String -> IO a-p parser s = case parse parser s s of-               Left err -> fail $ show err-               Right x  -> return x--test :: Parser CalendarTime -> String -> IO ()-test parser s = do t <- p parser s-                   putStrLn (s ++ " => " ++ showISO8601DateTime t)--main = do t <- timeNow-          let s = showISO8601DateTime t-          test parseISO8601DateTime s-          test parseEmptyDate ""-          test (string "date: " >> parseEmptyDate) ("date: ")-          test (string "date: " >> parseISO8601DateTime) ("date: " ++ s)
parsedate.cabal view
@@ -1,5 +1,5 @@ Name: parsedate-Version: 2006.6.4+Version: 2006.11.10 Copyright: Bjorn Bringert Maintainer: bjorn@bringert.net Author: Bjorn Bringert