X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=time-http.git;a=blobdiff_plain;f=Data%2FTime%2FAsctime.hs;h=0da530571a329787d82c91136f668b457f51febf;hp=7ebb59670f487507255c75f74244fbfc6ddbc5cc;hb=c6072393ea3d4d19639f410d2010b4815baad9e7;hpb=7ed69912b457694657e70496f695685493abcab5 diff --git a/Data/Time/Asctime.hs b/Data/Time/Asctime.hs index 7ebb596..0da5305 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 ' ' 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 @@ -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