From 91c2402d530afff7f1fd4eee333f84cbe18d1014 Mon Sep 17 00:00:00 2001 From: PHO Date: Wed, 14 Dec 2011 22:18:40 +0900 Subject: [PATCH] Rename modules Ditz-issue: 0a3272772c73cf31486eb2b6691fa38232d3c4c5 --- Data/Time/{ => Format}/Asctime.hs | 50 +++++++++++------------ Data/Time/{ => Format}/HTTP.hs | 21 ++++++---- Data/Time/{ => Format}/HTTP/Common.hs | 2 +- Data/Time/{ => Format}/RFC1123.hs | 14 ++++--- Data/Time/{ => Format}/RFC733.hs | 15 ++++--- Data/Time/{ => Format}/RFC822.hs | 6 +-- Data/Time/{ => Format}/RFC822/Internal.hs | 10 +++-- Test/Time/{ => Format}/HTTP.hs | 21 ++++------ time-http.cabal | 19 +++++---- 9 files changed, 86 insertions(+), 72 deletions(-) rename Data/Time/{ => Format}/Asctime.hs (70%) rename Data/Time/{ => Format}/HTTP.hs (89%) rename Data/Time/{ => Format}/HTTP/Common.hs (99%) rename Data/Time/{ => Format}/RFC1123.hs (88%) rename Data/Time/{ => Format}/RFC733.hs (94%) rename Data/Time/{ => Format}/RFC822.hs (90%) rename Data/Time/{ => Format}/RFC822/Internal.hs (94%) rename Test/Time/{ => Format}/HTTP.hs (92%) diff --git a/Data/Time/Asctime.hs b/Data/Time/Format/Asctime.hs similarity index 70% rename from Data/Time/Asctime.hs rename to Data/Time/Format/Asctime.hs index f8d28cc..8e280b5 100644 --- a/Data/Time/Asctime.hs +++ b/Data/Time/Format/Asctime.hs @@ -5,9 +5,9 @@ , TemplateHaskell , UnicodeSyntax #-} --- |This module provides functions for ANSI C's asctime() format. +-- |This module provides functions for ANSI C's date and time strings. -- --- ANSI C's asctime() format looks like: +-- ANSI C's @ctime(3)@/@asctime(3)@ format looks like: -- -- @Wdy Mon [D]D HH:MM:SS YYYY@ -- @@ -22,10 +22,7 @@ -- > day ::= 2DIGIT | SP 1DIGIT -- > 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 +module Data.Time.Format.Asctime ( Asctime , asctime ) @@ -39,10 +36,10 @@ import Data.Monoid.Unicode import Data.Tagged import Data.Time import Data.Time.Calendar.WeekDate -import Data.Time.HTTP.Common +import Data.Time.Format.HTTP.Common import Prelude.Unicode --- |The phantom type for conversion between ANSI C's @asctime()@ +-- |The phantom type for conversions between ANSI C's date and time -- string and 'LocalTime'. -- -- >>> convertSuccess (LocalTime (ModifiedJulianDay 49662) (TimeOfDay 8 49 37)) @@ -61,27 +58,28 @@ instance ConvertAttempt (Tagged Asctime Ascii) LocalTime where {-# INLINE convertAttempt #-} convertAttempt = parseAttempt' asctime ∘ untag --- |Parse an ANSI C's @asctime()@ string. +-- |Parse an ANSI C's date and time string. asctime ∷ Parser LocalTime -asctime = do weekDay ← shortWeekDayNameP - _ ← char ' ' - month ← shortMonthNameP - _ ← char ' ' - day ← read2' - _ ← char ' ' - hour ← read2 - _ ← char ':' - minute ← read2 - _ ← char ':' - second ← read2 - _ ← char ' ' - year ← read4 +asctime + = do weekDay ← shortWeekDayNameP + _ ← char ' ' + month ← shortMonthNameP + _ ← char ' ' + day ← read2' + _ ← char ' ' + hour ← read2 + _ ← char ':' + minute ← read2 + _ ← char ':' + second ← read2 + _ ← char ' ' + year ← read4 - gregDay ← assertGregorianDateIsGood year month day - _ ← assertWeekDayIsGood weekDay gregDay - tod ← assertTimeOfDayIsGood hour minute second + gregDay ← assertGregorianDateIsGood year month day + _ ← assertWeekDayIsGood weekDay gregDay + tod ← assertTimeOfDayIsGood hour minute second - return (LocalTime gregDay tod) + return (LocalTime gregDay tod) toAsciiBuilder ∷ LocalTime → AsciiBuilder toAsciiBuilder localTime diff --git a/Data/Time/HTTP.hs b/Data/Time/Format/HTTP.hs similarity index 89% rename from Data/Time/HTTP.hs rename to Data/Time/Format/HTTP.hs index 31d70e7..7e30cbf 100644 --- a/Data/Time/HTTP.hs +++ b/Data/Time/Format/HTTP.hs @@ -6,7 +6,8 @@ , UnicodeSyntax #-} -- |This module provides functions to parse and format HTTP\/1.1 date --- and time formats. +-- and time strings +-- (). -- -- The HTTP\/1.1 specification (RFC 2616) says that HTTP\/1.1 clients -- and servers which parse the date value MUST accept all the @@ -43,7 +44,7 @@ -- > month = "Jan" | "Feb" | "Mar" | "Apr" -- > | "May" | "Jun" | "Jul" | "Aug" -- > | "Sep" | "Oct" | "Nov" | "Dec" -module Data.Time.HTTP +module Data.Time.Format.HTTP ( HTTP , httpDateAndTime ) @@ -55,14 +56,18 @@ import Data.Attoparsec.Char8 import Data.Convertible.Base import Data.Tagged import Data.Time -import Data.Time.Asctime -import Data.Time.RFC1123 -import Data.Time.RFC733 -import Data.Time.RFC822 -import Data.Time.HTTP.Common +import Data.Time.Format.Asctime +import Data.Time.Format.HTTP.Common +import Data.Time.Format.RFC733 +import Data.Time.Format.RFC822 +import Data.Time.Format.RFC1123 import Prelude.Unicode --- |FIXME: doc +-- |The phantom type for conversions between HTTP/1.1 date and time +-- strings and 'UTCTime'. +-- +-- >>> convertSuccess (UTCTime (ModifiedJulianDay 49662) 31777) +-- Tagged "Sun, 06 Nov 1994 08:49:37 GMT" data HTTP instance ConvertSuccess UTCTime (Tagged HTTP Ascii) where diff --git a/Data/Time/HTTP/Common.hs b/Data/Time/Format/HTTP/Common.hs similarity index 99% rename from Data/Time/HTTP/Common.hs rename to Data/Time/Format/HTTP/Common.hs index c983389..b7e3b9e 100644 --- a/Data/Time/HTTP/Common.hs +++ b/Data/Time/Format/HTTP/Common.hs @@ -2,7 +2,7 @@ OverloadedStrings , UnicodeSyntax #-} -module Data.Time.HTTP.Common +module Data.Time.Format.HTTP.Common ( shortWeekDayName , shortWeekDayNameP diff --git a/Data/Time/RFC1123.hs b/Data/Time/Format/RFC1123.hs similarity index 88% rename from Data/Time/RFC1123.hs rename to Data/Time/Format/RFC1123.hs index cab3fb1..970dff1 100644 --- a/Data/Time/RFC1123.hs +++ b/Data/Time/Format/RFC1123.hs @@ -6,7 +6,7 @@ , UnicodeSyntax #-} -- |This module provides functions to parse and format RFC 1123 date --- and time formats. +-- and time strings (). -- -- The format is basically same as RFC 822, but the syntax for @date@ -- is changed from: @@ -16,7 +16,7 @@ -- to: -- -- > year ::= 4DIGIT -module Data.Time.RFC1123 +module Data.Time.Format.RFC1123 ( RFC1123 , rfc1123DateAndTime ) @@ -30,11 +30,15 @@ import Data.Monoid.Unicode import Data.Tagged import Data.Time import Data.Time.Calendar.WeekDate -import Data.Time.HTTP.Common -import Data.Time.RFC822.Internal +import Data.Time.Format.HTTP.Common +import Data.Time.Format.RFC822.Internal import Prelude.Unicode --- FIXME: doc +-- |The phantom type for conversions between RFC 1123 date and time +-- strings and 'ZonedTime'. +-- +-- >>> convertSuccess (ZonedTime (LocalTime (ModifiedJulianDay 49662) (TimeOfDay 8 49 37)) utc) +-- Tagged "Sun, 06 Nov 1994 08:49:37 GMT" data RFC1123 instance ConvertSuccess ZonedTime (Tagged RFC1123 Ascii) where diff --git a/Data/Time/RFC733.hs b/Data/Time/Format/RFC733.hs similarity index 94% rename from Data/Time/RFC733.hs rename to Data/Time/Format/RFC733.hs index 53a0b1e..e800310 100644 --- a/Data/Time/RFC733.hs +++ b/Data/Time/Format/RFC733.hs @@ -6,7 +6,7 @@ , UnicodeSyntax #-} -- |This module provides functions to parse and format RFC 733 date --- and time formats. +-- and time strings (). -- -- The syntax is as follows: -- @@ -44,7 +44,7 @@ -- > | "N" ; +1 -- > | "Y" ; +12 -- > | ("+" | "-") 4DIGIT ; Local diff: HHMM -module Data.Time.RFC733 +module Data.Time.Format.RFC733 ( RFC733 , rfc733DateAndTime ) @@ -58,11 +58,15 @@ import Data.Monoid.Unicode import Data.Tagged import Data.Time import Data.Time.Calendar.WeekDate -import Data.Time.RFC822.Internal -import Data.Time.HTTP.Common +import Data.Time.Format.HTTP.Common +import Data.Time.Format.RFC822.Internal import Prelude.Unicode --- FIXME: docs +-- |The phantom type for conversions between RFC 733 date and time +-- strings and 'ZonedTime'. +-- +-- >>> convertSuccess (ZonedTime (LocalTime (ModifiedJulianDay 49662) (TimeOfDay 8 49 37)) utc) +-- Tagged "Sunday, 06-Nov-1994 08:49:37 GMT" data RFC733 instance ConvertSuccess ZonedTime (Tagged RFC733 Ascii) where @@ -77,6 +81,7 @@ instance ConvertAttempt (Tagged RFC733 Ascii) ZonedTime where {-# INLINE convertAttempt #-} convertAttempt = parseAttempt' rfc733DateAndTime ∘ untag +-- |Parse an RFC 733 date and time string. rfc733DateAndTime ∷ Parser ZonedTime rfc733DateAndTime = dateTime diff --git a/Data/Time/RFC822.hs b/Data/Time/Format/RFC822.hs similarity index 90% rename from Data/Time/RFC822.hs rename to Data/Time/Format/RFC822.hs index b246e69..803d040 100644 --- a/Data/Time/RFC822.hs +++ b/Data/Time/Format/RFC822.hs @@ -1,5 +1,5 @@ -- |This module provides functions to parse and format RFC 822 date --- and time formats. +-- and time strings (). -- -- The syntax is as follows: -- @@ -27,9 +27,9 @@ -- > | "N" ; +1 -- > | "Y" ; +12 -- > | ("+" | "-") 4DIGIT ; Local diff: HHMM -module Data.Time.RFC822 +module Data.Time.Format.RFC822 ( RFC822 , rfc822DateAndTime ) where -import Data.Time.RFC822.Internal +import Data.Time.Format.RFC822.Internal diff --git a/Data/Time/RFC822/Internal.hs b/Data/Time/Format/RFC822/Internal.hs similarity index 94% rename from Data/Time/RFC822/Internal.hs rename to Data/Time/Format/RFC822/Internal.hs index 4fd701a..d1f62d2 100644 --- a/Data/Time/RFC822/Internal.hs +++ b/Data/Time/Format/RFC822/Internal.hs @@ -5,7 +5,7 @@ , TemplateHaskell , UnicodeSyntax #-} -module Data.Time.RFC822.Internal +module Data.Time.Format.RFC822.Internal ( RFC822 , rfc822DateAndTime , rfc822Time @@ -20,10 +20,14 @@ import Data.Monoid.Unicode import Data.Tagged import Data.Time import Data.Time.Calendar.WeekDate -import Data.Time.HTTP.Common +import Data.Time.Format.HTTP.Common import Prelude.Unicode --- |FIXME: docs +-- |The phantom type for conversions between RFC 822 date and time +-- strings and 'ZonedTime'. +-- +-- >>> convertSuccess (ZonedTime (LocalTime (ModifiedJulianDay 49662) (TimeOfDay 8 49 37)) utc) +-- Tagged "Sun, 06 Nov 94 08:49:37 GMT" data RFC822 instance ConvertSuccess ZonedTime (Tagged RFC822 Ascii) where diff --git a/Test/Time/HTTP.hs b/Test/Time/Format/HTTP.hs similarity index 92% rename from Test/Time/HTTP.hs rename to Test/Time/Format/HTTP.hs index 25e9e47..6555cdb 100644 --- a/Test/Time/HTTP.hs +++ b/Test/Time/Format/HTTP.hs @@ -12,11 +12,11 @@ import Data.Convertible.Base import Data.Proxy import Data.Tagged import Data.Time -import Data.Time.Asctime -import Data.Time.HTTP -import Data.Time.RFC733 -import Data.Time.RFC822 -import Data.Time.RFC1123 +import Data.Time.Format.Asctime +import Data.Time.Format.HTTP +import Data.Time.Format.RFC733 +import Data.Time.Format.RFC822 +import Data.Time.Format.RFC1123 import System.Exit import Prelude.Unicode import Test.QuickCheck @@ -97,8 +97,7 @@ tests = [ -- Asctime ≡ cs referenceLocalTime ) - , property $ \lt → Just lt ≡ fromAttempt (ca (cs (lt ∷ LocalTime) - ∷ Tagged Asctime Ascii)) + , property $ \lt → Just lt ≡ fromAttempt (ca (cs (lt ∷ LocalTime) ∷ Tagged Asctime Ascii)) -- RFC733 , property ( fromAttempt (ca (Tagged "Sunday, 06-Nov-94 08:49:37 GMT" ∷ Tagged RFC733 Ascii)) @@ -109,8 +108,7 @@ tests = [ -- Asctime ≡ cs referenceZonedTime ) - , property $ \zt → Just zt ≡ fromAttempt (ca (cs (zt ∷ ZonedTime) - ∷ Tagged RFC733 Ascii)) + , property $ \zt → Just zt ≡ fromAttempt (ca (cs (zt ∷ ZonedTime) ∷ Tagged RFC733 Ascii)) -- RFC822 , property ( fromAttempt (ca (Tagged "Sun, 06 Nov 94 08:49:37 GMT" ∷ Tagged RFC822 Ascii)) @@ -132,8 +130,7 @@ tests = [ -- Asctime ≡ cs referenceZonedTime ) - , property $ \zt → Just zt ≡ fromAttempt (ca (cs (zt ∷ ZonedTime) - ∷ Tagged RFC1123 Ascii)) + , property $ \zt → Just zt ≡ fromAttempt (ca (cs (zt ∷ ZonedTime) ∷ Tagged RFC1123 Ascii)) -- HTTP , property ( (Tagged "Sun, 06 Nov 1994 08:49:37 GMT" ∷ Tagged HTTP Ascii) @@ -141,7 +138,7 @@ tests = [ -- Asctime ) , property $ \ut → Just ut ≡ fromAttempt (ca (cs ut ∷ Tagged HTTP Ascii) ∷ Attempt UTCTime) , property $ \ut → Just ut ≡ fromAttempt (ca (retagHTTP (cs (ut2lt ut) ∷ Tagged Asctime Ascii))) - , property $ \ut → Just ut ≡ fromAttempt (ca (retagHTTP (cs (ut2zt ut) ∷ Tagged RFC733 Ascii))) + , property $ \ut → Just ut ≡ fromAttempt (ca (retagHTTP (cs (ut2zt ut) ∷ Tagged RFC733 Ascii))) , property $ \ut → Just (untag ut) ≡ fromAttempt (ca (retagHTTP (cs (ut2zt (untag (ut ∷ Tagged Cent20 UTCTime))) ∷ Tagged RFC822 Ascii))) , property $ \ut → Just ut ≡ fromAttempt (ca (retagHTTP (cs (ut2zt ut) ∷ Tagged RFC1123 Ascii))) diff --git a/time-http.cabal b/time-http.cabal index 270160e..678a36b 100644 --- a/time-http.cabal +++ b/time-http.cabal @@ -3,7 +3,8 @@ Version: 0.3 Synopsis: Parse and format HTTP/1.1 Date and Time strings Description: This package provides functionalities to parse and format - various Date and Time formats allowed in HTTP\/1.1 (RFC 2616). + various Date and Time formats allowed in HTTP\/1.1 + (). Homepage: http://cielonegro.org/HTTPDateTime.html Bug-Reports: http://static.cielonegro.org/ditz/time-http/ @@ -26,15 +27,15 @@ Source-Repository head Library Exposed-modules: - Data.Time.Asctime - Data.Time.HTTP - Data.Time.RFC1123 - Data.Time.RFC733 - Data.Time.RFC822 + Data.Time.Format.Asctime + Data.Time.Format.RFC733 + Data.Time.Format.RFC822 + Data.Time.Format.RFC1123 + Data.Time.Format.HTTP Other-modules: - Data.Time.HTTP.Common - Data.Time.RFC822.Internal + Data.Time.Format.HTTP.Common + Data.Time.Format.RFC822.Internal Build-depends: ascii == 0.0.*, @@ -57,7 +58,7 @@ Library Test-Suite test-time-http Type: exitcode-stdio-1.0 - Main-Is: Test/Time/HTTP.hs + Main-Is: Test/Time/Format/HTTP.hs Default-Language: Haskell2010 Build-depends: QuickCheck == 2.4.*, -- 2.40.0