X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=time-http.git;a=blobdiff_plain;f=Data%2FTime%2FFormat%2FAsctime.hs;fp=Data%2FTime%2FAsctime.hs;h=8e280b54f4cf1e860b07604ecb53e912f22d3b4b;hp=f8d28ccd80091fb0424c779245aaa6627d50068a;hb=91c2402d530afff7f1fd4eee333f84cbe18d1014;hpb=7fd4893fdd44f360647fa99c7f96ed96d2f7bac4 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