Permalink
Browse files

Remove conversion from timestamp (no TZ) to UTCTime

  • Loading branch information...
1 parent 094b560 commit ecdbc742d9d07db504a79330d5cdbfcd88a732e0 @lpsmith committed Jun 10, 2012
Showing with 2 additions and 13 deletions.
  1. +2 −12 src/Database/PostgreSQL/Simple/FromField.hs
  2. +0 −1 src/Database/PostgreSQL/Simple/ToField.hs
View
14 src/Database/PostgreSQL/Simple/FromField.hs
@@ -51,8 +51,7 @@ import qualified Data.ByteString.Char8 as B
import Data.Int (Int16, Int32, Int64)
import Data.List (foldl')
import Data.Ratio (Ratio)
-import Data.Time ( UTCTime, ZonedTime, LocalTime, Day, TimeOfDay
- , localTimeToUTC, utc )
+import Data.Time ( UTCTime, ZonedTime, LocalTime, Day, TimeOfDay )
import Data.Typeable (Typeable, typeOf)
import Data.Word (Word64)
import Database.PostgreSQL.Simple.Internal
@@ -194,16 +193,7 @@ instance FromField [Char] where
fromField f dat = ST.unpack <$> fromField f dat
instance FromField UTCTime where
- fromField f =
- case oid2builtin (typeOid f) of
- Just TimestampWithTimeZone -> doIt id parseUTCTime
- Just Timestamp -> doIt (localTimeToUTC utc) parseLocalTime -- deprecated
- _ -> const $ returnError Incompatible f ""
- where
- doIt _finish _parse Nothing
- = returnError UnexpectedNull f ""
- doIt finish parse (Just bs)
- = either (returnError ConversionFailed f) (pure . finish) (parse bs)
+ fromField = ff TimestampWithTimeZone "UTCTime" parseUTCTime
instance FromField ZonedTime where
fromField = ff TimestampWithTimeZone "ZonedTime" parseZonedTime
View
1 src/Database/PostgreSQL/Simple/ToField.hs
@@ -32,7 +32,6 @@ import Data.Time (Day, TimeOfDay, LocalTime, UTCTime, ZonedTime)
import Data.Typeable (Typeable)
import Data.Word (Word, Word8, Word16, Word32, Word64)
import Database.PostgreSQL.Simple.Types (Binary(..), In(..), Null)
-import System.Locale (defaultTimeLocale)
import qualified Blaze.ByteString.Builder.Char.Utf8 as Utf8
import qualified Data.ByteString as SB
import qualified Data.ByteString.Lazy as LB

0 comments on commit ecdbc74

Please sign in to comment.