git.iko.soy/typeable/postgresql-simple
on master help sign in
Allow Z to designate UTC in getTimeZoneHMS as well
f2779dbLeon P Smith
src/Database/PostgreSQL/Simple/Time/Implementation.hs+10−7
@@ -151,13 +151,16 @@ type TimeZoneHMS = (Int,Int,Int)
151
151
152getTimeZoneHMS :: A.Parser TimeZoneHMS
152getTimeZoneHMS :: A.Parser TimeZoneHMS
153getTimeZoneHMS = do
153getTimeZoneHMS = do
154− !sign <- A.satisfy (\c -> c == '+' || c == '-')
154+ !sign <- A.satisfy (\c -> c == '+' || c == '-' || c == 'Z')
155+ if sign == 'Z'
156+ then return (0,0,0)
157+ else do
155− !hours <- digits "timezone"
158+ !hours <- digits "timezone"
156− !mins <- (A.char ':' *> digits "timezone minutes") <|> pure 0
159+ !mins <- (A.char ':' *> digits "timezone minutes") <|> pure 0
157− !secs <- (A.char ':' *> digits "timezone seconds") <|> pure 0
160+ !secs <- (A.char ':' *> digits "timezone seconds") <|> pure 0
158− if sign == '+'
161+ if sign == '+'
159− then return $! (hours, mins, secs)
162+ then return $! (hours, mins, secs)
160− else return $! (\ !h !m !s -> (h,m,s)) (-hours) (-mins) (-secs)
163+ else return $! (\ !h !m !s -> (h,m,s)) (-hours) (-mins) (-secs)
161
164
162localToUTCTimeOfDayHMS :: TimeZoneHMS -> TimeOfDay -> (Integer, TimeOfDay)
165localToUTCTimeOfDayHMS :: TimeZoneHMS -> TimeOfDay -> (Integer, TimeOfDay)
163localToUTCTimeOfDayHMS (dh, dm, ds) (TimeOfDay h m s) =
166localToUTCTimeOfDayHMS (dh, dm, ds) (TimeOfDay h m s) =