@@ -177,11 +177,18 @@ instance Result [Char] where
177177 convert f dat = ST.unpack <$> convert f dat
178178
179179instance Result UTCTime where
180− convert f = doConvert f ok $ \bs ->
181− case parseTime defaultTimeLocale "%F %T%Q%z" (B8.unpack bs ++ "00") of
182− Just t -> Right t
183− Nothing -> returnError ConversionFailed f "could not parse"
184− where ok = mkCompats [TimestampWithTimeZone]
180+ convert f =
181+ case oid2builtin (typeOid f) of
182+ Just Timestamp -> doIt "%F %T%Q" id
183+ Just TimestampWithTimeZone -> doIt "%F %T%Q%z" (++ "00")
184+ _ -> const $ returnError Incompatible f "types incompatible"
185+ where
186+ doIt _ _ Nothing = returnError UnexpectedNull f ""
187+ doIt fmt preprocess (Just bs) =
188+ case parseTime defaultTimeLocale fmt str of
189+ Just t -> Right t
190+ Nothing -> returnError ConversionFailed f "could not parse"
191+ where str = preprocess (B8.unpack bs)
185192
186193instance Result Day where
187194 convert f = atto ok date f