]> gitweb @ CieloNegro.org - time-http.git/blobdiff - Data/Time/RFC822.hs
RFC822.Internal
[time-http.git] / Data / Time / RFC822.hs
index 4c8e333d6f294d2435a6a2db46338ec16e969001..b246e696cbc7589a7e524517664690a548b1fa2f 100644 (file)
@@ -1,5 +1,3 @@
-{-# OPTIONS_HADDOCK prune #-}
-
 -- |This module provides functions to parse and format RFC 822 date
 -- and time formats.
 --
 -- >               | "Y"                ; +12
 -- >               | ("+" | "-") 4DIGIT ; Local diff: HHMM
 module Data.Time.RFC822
-    ( format
-    , parse
-
-    -- private
-    , showRFC822TimeZone
+    ( RFC822
+    , rfc822DateAndTime
     )
     where
-
-import qualified Text.Parsec as P
-
-import Data.Time
-import Data.Time.Calendar.WeekDate
-import Data.Time.HTTP.Common
-import Data.Time.RFC822.Parsec
-
--- |Format a 'ZonedTime' in RFC 822.
-format :: ZonedTime -> String
-format zonedTime
-    = let localTime          = zonedTimeToLocalTime zonedTime
-          timeZone           = zonedTimeZone zonedTime
-          (year, month, day) = toGregorian (localDay localTime)
-          (_, _, week)       = toWeekDate  (localDay localTime)
-          timeOfDay          = localTimeOfDay localTime
-      in
-        concat [ shortWeekDayName week
-               , ", "
-               , show2 day
-               , " "
-               , shortMonthName month
-               , " "
-               , show2 (year `mod` 100)
-               , " "
-               , show2 (todHour timeOfDay)
-               , ":"
-               , show2 (todMin timeOfDay)
-               , ":"
-               , show2 (floor (todSec timeOfDay))
-               , " "
-               , showRFC822TimeZone timeZone
-               ]
-
-showRFC822TimeZone :: TimeZone -> String
-showRFC822TimeZone tz
-    | timeZoneMinutes tz == 0 = "GMT"
-    | otherwise               = show4digitsTZ tz
-
--- |Parse an RFC 822 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
-              Left  _  -> Nothing
-    where
-      p = do zt <- rfc822DateAndTime
-             _  <- P.eof
-             return zt
+import Data.Time.RFC822.Internal