File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -124,7 +124,7 @@ common pkg-prelude
124
124
, template-haskell
125
125
, text
126
126
, th-lift-instances
127
- , time
127
+ , time >= 1.11.1.1
128
128
, transformers
129
129
, unbounded-delays
130
130
, uniplate
Original file line number Diff line number Diff line change @@ -66,6 +66,29 @@ instance Toml.HasItemCodec URI where
66
66
$ Toml. Text
67
67
. URI. render
68
68
69
+ instance Toml. HasCodec UTCTime where
70
+ hasCodec =
71
+ Toml. textBy (from @ String @ Text . iso8601Show)
72
+ $ maybe (Left " Not a UTCTime" ) pure
73
+ . iso8601ParseM
74
+ . from @ Text @ String
75
+
76
+ instance Toml. HasItemCodec UTCTime where
77
+ hasItemCodec =
78
+ Left
79
+ . Toml. mkAnyValueBiMap
80
+ ( \ src -> do
81
+ txt <- Toml. matchText src
82
+ maybe
83
+ (Left . Toml. MatchError Toml. TText $ Toml. AnyValue src)
84
+ pure
85
+ . iso8601ParseM
86
+ $ from @ Text @ String txt
87
+ )
88
+ $ Toml. Text
89
+ . from @ String @ Text
90
+ . iso8601Show
91
+
69
92
instance (Show a , Enum a , Bounded a ) => Toml. HasCodec (GenericEnum a ) where
70
93
hasCodec = Toml. enumBounded
71
94
Original file line number Diff line number Diff line change @@ -274,6 +274,7 @@ import Data.Time.Clock as X
274
274
)
275
275
import qualified Data.Time.Clock as Clock
276
276
import Data.Time.Clock.POSIX as X (posixSecondsToUTCTime )
277
+ import Data.Time.Format.ISO8601 as X (iso8601ParseM , iso8601Show )
277
278
import Data.Tuple.Extra as X (thd3 , uncurry3 )
278
279
import qualified Data.Typeable as Typeable
279
280
import Functora.PreludeOrphan as X ()
You can’t perform that action at this time.
0 commit comments