]> gitweb @ CieloNegro.org - time-http.git/blobdiff - Data/Time/Asctime/Internal.hs
Changed some module's name
[time-http.git] / Data / Time / Asctime / Internal.hs
diff --git a/Data/Time/Asctime/Internal.hs b/Data/Time/Asctime/Internal.hs
new file mode 100644 (file)
index 0000000..85707c6
--- /dev/null
@@ -0,0 +1,32 @@
+{-# LANGUAGE FlexibleContexts #-}
+module Data.Time.Asctime.Internal
+    ( asctime
+    )
+    where
+import Control.Monad
+import Data.Fixed
+import Data.Time
+import Data.Time.Calendar.WeekDate
+import Data.Time.HTTP.Common
+
+-- |This is a parsec parser for ANSI C's asctime() format.
+asctime :: Stream s m Char => ParsecT s u m LocalTime
+asctime = do weekDay <- shortWeekDayNameP
+             _       <- string ", "
+             month   <- shortMonthNameP
+             _       <- char ' '
+             day     <- read2
+             _       <- char ' '
+             hour    <- read2
+             _       <- char ':'
+             minute  <- read2
+             _       <- char ':'
+             second  <- read2
+             _       <- char ' '
+             year    <- read4
+
+             gregDay <- assertGregorianDateIsGood year month day
+             _       <- assertWeekDayIsGood weekDay gregDay
+             tod     <- assertTimeOfDayIsGood hour minute second
+
+             return (LocalTime gregDay tod)