X-Git-Url: http://git.cielonegro.org/gitweb.cgi?p=time-http.git;a=blobdiff_plain;f=Data%2FTime%2FAsctime.hs;h=f8d28ccd80091fb0424c779245aaa6627d50068a;hp=f7d7bddaa64114ad20728428119d6d38b6ae2e49;hb=782e6a9;hpb=127b8db10ba98b77b5549902f4759f09a19604b1 diff --git a/Data/Time/Asctime.hs b/Data/Time/Asctime.hs index f7d7bdd..f8d28cc 100644 --- a/Data/Time/Asctime.hs +++ b/Data/Time/Asctime.hs @@ -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 |]) + ]