git.iko.soy/typeable/postgresql-simple
on master help sign in
Remove some now-unnecessary code
f62ebe3Leon P Smith
src/Database/PostgreSQL/Simple/Time/Implementation.hs+4−38
@@ -8,7 +8,7 @@
8--
8--
9------------------------------------------------------------------------------
9------------------------------------------------------------------------------
10
10
11−{-# LANGUAGE DeriveDataTypeable, DeriveFunctor, CPP #-}
11+{-# LANGUAGE DeriveDataTypeable, DeriveFunctor #-}
12
12
13module Database.PostgreSQL.Simple.Time.Implementation where
13module Database.PostgreSQL.Simple.Time.Implementation where
14
14
@@ -16,7 +16,6 @@ import Prelude hiding (take)
16import Data.ByteString.Builder(Builder, byteString, char8, integerDec)
16import Data.ByteString.Builder(Builder, byteString, char8, integerDec)
17import Control.Arrow((***))
17import Control.Arrow((***))
18import Control.Applicative
18import Control.Applicative
19−import Control.Monad(when)
20import Data.Bits((.&.))
19import Data.Bits((.&.))
21import qualified Data.ByteString as B
20import qualified Data.ByteString as B
22import Data.ByteString.Internal (c2w, w2c)
21import Data.ByteString.Internal (c2w, w2c)
@@ -30,26 +29,7 @@ import Data.Monoid(Monoid(..))
30import Data.Fixed (Pico)
29import Data.Fixed (Pico)
31import Unsafe.Coerce
30import Unsafe.Coerce
32import qualified Database.PostgreSQL.Simple.Time.Parser as TP
31import qualified Database.PostgreSQL.Simple.Time.Parser as TP
33−
32+import Database.PostgreSQL.Simple.Compat (fromPico)
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−
53
33
54data Unbounded a
34data Unbounded a
55 = NegInfinity
35 = NegInfinity
@@ -135,22 +115,8 @@ getTimeZoneHMS = munge <$> TP.timeZoneHMS
135 munge (Just (TP.UTCOffsetHMS h m s)) = (h,m,s)
115 munge (Just (TP.UTCOffsetHMS h m s)) = (h,m,s)
136
116
137localToUTCTimeOfDayHMS :: TimeZoneHMS -> TimeOfDay -> (Integer, TimeOfDay)
117localToUTCTimeOfDayHMS :: TimeZoneHMS -> TimeOfDay -> (Integer, TimeOfDay)
138−localToUTCTimeOfDayHMS (dh, dm, ds) (TimeOfDay h m s) =
118+localToUTCTimeOfDayHMS (dh, dm, ds) tod =
139− (\ !a !b -> (a,b)) dday (TimeOfDay h'' m'' s'')
119+ TP.localToUTCTimeOfDayHMS (TP.UTCOffsetHMS dh dm ds) tod
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)
154
120
155getZonedTime :: A.Parser ZonedTime
121getZonedTime :: A.Parser ZonedTime
156getZonedTime = TP.zonedTime
122getZonedTime = TP.zonedTime