]> gitweb @ CieloNegro.org - time-http.git/blobdiff - Data/Time/Asctime.hs
Rewrote RFC733
[time-http.git] / Data / Time / Asctime.hs
index f7d7bddaa64114ad20728428119d6d38b6ae2e49..f8d28ccd80091fb0424c779245aaa6627d50068a 100644 (file)
@@ -2,6 +2,7 @@
     FlexibleInstances
   , MultiParamTypeClasses
   , OverloadedStrings
+  , TemplateHaskell
   , UnicodeSyntax
   #-}
 -- |This module provides functions for ANSI C's asctime() format.
@@ -43,24 +44,19 @@ import Prelude.Unicode
 
 -- |The phantom type for conversion between ANSI C's @asctime()@
 -- string and 'LocalTime'.
+--
+-- >>> convertSuccess (LocalTime (ModifiedJulianDay 49662) (TimeOfDay 8 49 37))
+-- Tagged "Sun Nov  6 08:49:37 1994"
 data Asctime
 
 instance ConvertSuccess LocalTime (Tagged Asctime Ascii) where
     {-# INLINE convertSuccess #-}
     convertSuccess = (A.fromAsciiBuilder <$>) ∘ cs
 
-instance ConvertAttempt LocalTime (Tagged Asctime Ascii) where
-    {-# INLINE convertAttempt #-}
-    convertAttempt = return ∘ cs
-
 instance ConvertSuccess LocalTime (Tagged Asctime AsciiBuilder) where
     {-# INLINE convertSuccess #-}
     convertSuccess = Tagged ∘ toAsciiBuilder
 
-instance ConvertAttempt LocalTime (Tagged Asctime AsciiBuilder) where
-    {-# INLINE convertAttempt #-}
-    convertAttempt = return ∘ cs
-
 instance ConvertAttempt (Tagged Asctime Ascii) LocalTime where
     {-# INLINE convertAttempt #-}
     convertAttempt = parseAttempt' asctime ∘ untag
@@ -106,3 +102,7 @@ toAsciiBuilder localTime
         ⊕ show2 (floor (todSec timeOfDay) ∷ Int)
         ⊕ A.toAsciiBuilder " "
         ⊕ show4 year
+
+deriveAttempts [ ([t| LocalTime |], [t| Tagged Asctime Ascii        |])
+               , ([t| LocalTime |], [t| Tagged Asctime AsciiBuilder |])
+               ]