X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=time-http.git;a=blobdiff_plain;f=Data%2FTime%2FAsctime.hs;h=fd5cca01f994d8dde7f733e89344c1ccad69a201;hp=7ebb59670f487507255c75f74244fbfc6ddbc5cc;hb=469170632eee26999634929f964d9cc71e068bf3;hpb=e90df736d33162bb7ade70cb6fe1372a28af62ff diff --git a/Data/Time/Asctime.hs b/Data/Time/Asctime.hs index 7ebb596..fd5cca0 100644 --- a/Data/Time/Asctime.hs +++ b/Data/Time/Asctime.hs @@ -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 SP month SP day SP time SP 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 @@ -11,10 +31,7 @@ import Data.Time.Calendar.WeekDate 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) @@ -36,6 +53,8 @@ format localTime , 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