]> gitweb @ CieloNegro.org - time-http.git/commitdiff
haddock comments
authorPHO <pho@cielonegro.org>
Thu, 18 Mar 2010 04:08:53 +0000 (13:08 +0900)
committerPHO <pho@cielonegro.org>
Thu, 18 Mar 2010 04:08:53 +0000 (13:08 +0900)
Data/Time/Asctime.hs
Data/Time/Asctime/Parsec.hs

index 7ebb59670f487507255c75f74244fbfc6ddbc5cc..0da530571a329787d82c91136f668b457f51febf 100644 (file)
@@ -1,3 +1,23 @@
+-- |This module is for ANSI C's asctime() format.
+--
+-- ANSI C's asctime() format looks like:
+--
+-- @Wdy Mon DD HH:MM:SS YYYY@
+--
+-- The exact syntax is as follows:
+--
+-- > date-time ::= wday ' ' month ' ' day ' ' time ' ' year
+-- > wday      ::= "Mon" | "Tue" | "Wed" | "Thu"
+-- >             | "Fri" | "Sat" | "Sun"
+-- > month     ::= "Jan" | "Feb" | "Mar" | "Apr"
+-- >             | "May" | "Jun" | "Jul" | "Aug"
+-- >             | "Sep" | "Oct" | "Nov" | "Dec"
+-- > day       ::= 2DIGIT
+-- > time      ::= 2DIGIT ':' 2DIGIT [':' 2DIGIT]
+-- > year      ::= 4DIGIT
+--
+-- As you can see, it has no time zone info. "Data.Time.HTTP" will
+-- treat it as UTC.
 module Data.Time.Asctime
     ( format
     , parse
 module Data.Time.Asctime
     ( format
     , parse
@@ -11,10 +31,7 @@ import Data.Time.Calendar.WeekDate
 import Data.Time.HTTP.Common
 import Data.Time.Asctime.Parsec
 
 import Data.Time.HTTP.Common
 import Data.Time.Asctime.Parsec
 
-{-
-  Wdy Mon DD HH:MM:SS YYYY
--}
-
+-- |Format a 'LocalTime' in the ANSI C's asctime() way.
 format :: LocalTime -> String
 format localTime
     = let (year, month, day) = toGregorian (localDay localTime)
 format :: LocalTime -> String
 format localTime
     = let (year, month, day) = toGregorian (localDay localTime)
@@ -36,6 +53,8 @@ format localTime
                , show4 year
                ]
 
                , show4 year
                ]
 
+-- |Parse an ANSI C's asctime() format to 'LocalTime'. When the string
+-- can't be parsed, it returns 'Nothing'.
 parse :: String -> Maybe LocalTime
 parse src = case P.parse p "" src of
               Right zt -> Just zt
 parse :: String -> Maybe LocalTime
 parse src = case P.parse p "" src of
               Right zt -> Just zt
index 3cff94ca42b3fab4e737d9c188df4f893b312ab8..201f347f2b99cc9370097f5ca97c58de67d9a794 100644 (file)
@@ -11,7 +11,7 @@ import Data.Time.Calendar.WeekDate
 import Data.Time.HTTP.Common
 import Text.Parsec
 
 import Data.Time.HTTP.Common
 import Text.Parsec
 
-
+-- |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 ", "
 asctime :: Stream s m Char => ParsecT s u m LocalTime
 asctime = do weekDay <- shortWeekDayNameP
              _       <- string ", "