@@ -8,7 +8,7 @@
88--
99------------------------------------------------------------------------------
1010
11−{-# LANGUAGE DeriveDataTypeable, DeriveFunctor, CPP #-}
11+{-# LANGUAGE DeriveDataTypeable, DeriveFunctor #-}
1212
1313module Database.PostgreSQL.Simple.Time.Implementation where
1414
@@ -16,7 +16,6 @@ import Prelude hiding (take)
1616import Data.ByteString.Builder(Builder, byteString, char8, integerDec)
1717import Control.Arrow((***))
1818import Control.Applicative
19−import Control.Monad(when)
2019import Data.Bits((.&.))
2120import qualified Data.ByteString as B
2221import Data.ByteString.Internal (c2w, w2c)
@@ -30,26 +29,7 @@ import Data.Monoid(Monoid(..))
3029import Data.Fixed (Pico)
3130import Unsafe.Coerce
3231import qualified Database.PostgreSQL.Simple.Time.Parser as TP
33−
34−#if !MIN_VERSION_base(4,7,0)
35−-- A kludge to work around the fact that Data.Fixed isn't very fast and
36−-- previously didn't give me access to the MkFixed constructor.
37−
38−mkPico :: Integer -> Pico
39−mkPico = unsafeCoerce
40−
41−fromPico :: Pico -> Integer
42−fromPico = unsafeCoerce
43−#else
44−import Data.Fixed(Fixed(MkFixed))
45−
46−mkPico :: Integer -> Pico
47−mkPico = MkFixed
48−
49−fromPico :: Pico -> Integer
50−fromPico (MkFixed x) = x
51−#endif
52−
32+import Database.PostgreSQL.Simple.Compat (fromPico)
5333
5434data Unbounded a
5535 = NegInfinity
@@ -135,22 +115,8 @@ getTimeZoneHMS = munge <$> TP.timeZoneHMS
135115 munge (Just (TP.UTCOffsetHMS h m s)) = (h,m,s)
136116
137117localToUTCTimeOfDayHMS :: TimeZoneHMS -> TimeOfDay -> (Integer, TimeOfDay)
138−localToUTCTimeOfDayHMS (dh, dm, ds) (TimeOfDay h m s) =
139− (\ !a !b -> (a,b)) dday (TimeOfDay h'' m'' s'')
140− where
141− s' = s - fromIntegral ds
142− (!s'', m')
143− | s' < 0 = (s' + 60, m - dm - 1)
144− | s' >= 60 = (s' - 60, m - dm + 1)
145− | otherwise = (s' , m - dm )
146− (!m'', h')
147− | m' < 0 = (m' + 60, h - dh - 1)
148− | m' >= 60 = (m' - 60, h - dh + 1)
149− | otherwise = (m' , h - dh )
150− (!h'', dday)
151− | h' < 0 = (h' + 24, -1)
152− | h' >= 24 = (h' - 24, 1)
153− | otherwise = (h' , 0)
118+localToUTCTimeOfDayHMS (dh, dm, ds) tod =
119+ TP.localToUTCTimeOfDayHMS (TP.UTCOffsetHMS dh dm ds) tod
154120
155121getZonedTime :: A.Parser ZonedTime
156122getZonedTime = TP.zonedTime