FlexibleInstances
, MultiParamTypeClasses
, OverloadedStrings
+ , TemplateHaskell
, UnicodeSyntax
#-}
-- |This module provides functions for ANSI C's asctime() format.
-- |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
⊕ show2 (floor (todSec timeOfDay) ∷ Int)
⊕ A.toAsciiBuilder " "
⊕ show4 year
+
+deriveAttempts [ ([t| LocalTime |], [t| Tagged Asctime Ascii |])
+ , ([t| LocalTime |], [t| Tagged Asctime AsciiBuilder |])
+ ]