@@ -54,7 +54,7 @@ import Data.Ratio (Ratio)
5454import Data.Time.Calendar (Day, fromGregorian)
5555import Data.Time.Clock (UTCTime)
5656import Data.Time.Format (parseTime)
57−import Data.Time.LocalTime (TimeOfDay, makeTimeOfDayValid)
57+import Data.Time.LocalTime (ZonedTime, TimeOfDay, makeTimeOfDayValid)
5858import Data.Typeable (Typeable, typeOf)
5959import Data.Word (Word64)
6060import Database.PostgreSQL.Simple.Internal
@@ -209,6 +209,19 @@ instance FromField UTCTime where
209209 Nothing -> returnError ConversionFailed f "could not parse"
210210 where str = preprocess (B8.unpack bs)
211211
212+instance FromField ZonedTime where
213+ fromField f =
214+ case oid2builtin (typeOid f) of
215+ Just TimestampWithTimeZone -> doIt "%F %T%Q%z" (++ "00")
216+ _ -> const $ returnError Incompatible f "types incompatible"
217+ where
218+ doIt _ _ Nothing = returnError UnexpectedNull f ""
219+ doIt fmt preprocess (Just bs) =
220+ case parseTime defaultTimeLocale fmt str of
221+ Just t -> pure t
222+ Nothing -> returnError ConversionFailed f "could not parse"
223+ where str = preprocess (B8.unpack bs)
224+
212225instance FromField Day where
213226 fromField f = atto ok date f
214227 where ok = mkCompats [Date]