X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=time-http.git;a=blobdiff_plain;f=Data%2FTime%2FRFC1123.hs;h=93aeb7e2d924d0a5ee85112c376835a6baac7b0b;hp=abb0a6d53e882eee4e70aaf27e3ea928a1cbce92;hb=82afb594c5b4254385435491700befcbea185a5d;hpb=269a28dfe8b08af854f7217bbe9c141c9c18f1ec diff --git a/Data/Time/RFC1123.hs b/Data/Time/RFC1123.hs index abb0a6d..93aeb7e 100644 --- a/Data/Time/RFC1123.hs +++ b/Data/Time/RFC1123.hs @@ -1,22 +1,26 @@ +-- |This module provides functions to parse and format RFC 1123 date +-- and time formats. +-- +-- The format is basically same as RFC 822, but the syntax for @date@ +-- is changed from: +-- +-- > year ::= 2DIGIT +-- +-- to: +-- +-- > year ::= 4DIGIT module Data.Time.RFC1123 ( format , parse ) where - -import qualified Text.Parsec as P - import Data.Time import Data.Time.Calendar.WeekDate import Data.Time.HTTP.Common -import Data.Time.RFC1123.Parsec - -{- - The syntax for the date is hereby changed to: - - date = 1*2DIGIT month 2*4DIGIT --} +import Data.Time.RFC822 (showRFC822TimeZone) +import Data.Time.RFC1123.Internal +-- |Format a 'ZonedTime' in RFC 1123. format :: ZonedTime -> String format zonedTime = let localTime = zonedTimeToLocalTime zonedTime @@ -39,9 +43,11 @@ format zonedTime , ":" , show2 (floor (todSec timeOfDay)) , " " - , show4digitsTZ timeZone + , showRFC822TimeZone timeZone ] +-- |Parse an RFC 1123 date and time string. When the string can't be +-- parsed, it returns 'Nothing'. parse :: String -> Maybe ZonedTime parse src = case P.parse p "" src of Right zt -> Just zt