[commit: packages/time] : fix type of exposed function timeZoneOffsetString' (94777bd)
git at git.haskell.org
git at git.haskell.org
Mon Feb 20 21:21:03 UTC 2017
Repository : ssh://git@git.haskell.org/time
On branch :
Link : http://git.haskell.org/packages/time.git/commitdiff/94777bd038b6a5a03e379c9540406a58dd87bb39
>---------------------------------------------------------------
commit 94777bd038b6a5a03e379c9540406a58dd87bb39
Author: Ashley Yakeley <ashley at yakeley.org>
Date: Mon Feb 13 19:29:30 2017 -0800
fix type of exposed function timeZoneOffsetString'
>---------------------------------------------------------------
94777bd038b6a5a03e379c9540406a58dd87bb39
lib/Data/Time/Format.hs | 4 ++--
lib/Data/Time/LocalTime.hs | 9 +++++++--
lib/Data/Time/LocalTime/Internal/TimeZone.hs | 14 +++++++++-----
3 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/lib/Data/Time/Format.hs b/lib/Data/Time/Format.hs
index 4869e67..7cea584 100644
--- a/lib/Data/Time/Format.hs
+++ b/lib/Data/Time/Format.hs
@@ -290,10 +290,10 @@ instance FormatTime ZonedTime where
Nothing -> Nothing
instance FormatTime TimeZone where
- formatCharacter 'z' = Just $ padGeneral False True 4 '0' $ \_ pado -> showPadded pado . timeZoneOffsetString' pado
+ formatCharacter 'z' = Just $ padGeneral False True 4 '0' $ \_ pado -> showPadded pado . timeZoneOffsetString'' pado
formatCharacter 'Z' = Just $ \locale mnpo mi z -> let
n = timeZoneName z
- in if null n then timeZoneOffsetString' (getPadOption False True 4 '0' mnpo mi) z else padString (\_ -> timeZoneName) locale mnpo mi z
+ in if null n then timeZoneOffsetString'' (getPadOption False True 4 '0' mnpo mi) z else padString (\_ -> timeZoneName) locale mnpo mi z
formatCharacter _ = Nothing
instance FormatTime Day where
diff --git a/lib/Data/Time/LocalTime.hs b/lib/Data/Time/LocalTime.hs
index d450d85..296fce9 100644
--- a/lib/Data/Time/LocalTime.hs
+++ b/lib/Data/Time/LocalTime.hs
@@ -1,13 +1,18 @@
module Data.Time.LocalTime
(
- module Data.Time.LocalTime.Internal.TimeZone,
+ -- * Time zones
+ TimeZone(..),timeZoneOffsetString,timeZoneOffsetString',minutesToTimeZone,hoursToTimeZone,utc,
+
+ -- getting the locale time zone
+ getTimeZone,getCurrentTimeZone,
+
module Data.Time.LocalTime.Internal.TimeOfDay,
module Data.Time.LocalTime.Internal.LocalTime,
module Data.Time.LocalTime.Internal.ZonedTime,
) where
import Data.Time.Format()
-import Data.Time.LocalTime.Internal.TimeZone
+import Data.Time.LocalTime.Internal.TimeZone hiding (timeZoneOffsetString'')
import Data.Time.LocalTime.Internal.TimeOfDay
import Data.Time.LocalTime.Internal.LocalTime
import Data.Time.LocalTime.Internal.ZonedTime
diff --git a/lib/Data/Time/LocalTime/Internal/TimeZone.hs b/lib/Data/Time/LocalTime/Internal/TimeZone.hs
index 40d6092..fe434b7 100644
--- a/lib/Data/Time/LocalTime/Internal/TimeZone.hs
+++ b/lib/Data/Time/LocalTime/Internal/TimeZone.hs
@@ -6,7 +6,7 @@
module Data.Time.LocalTime.Internal.TimeZone
(
-- * Time zones
- TimeZone(..),timeZoneOffsetString,timeZoneOffsetString',minutesToTimeZone,hoursToTimeZone,utc,
+ TimeZone(..),timeZoneOffsetString,timeZoneOffsetString',timeZoneOffsetString'',minutesToTimeZone,hoursToTimeZone,utc,
-- getting the locale time zone
getTimeZone,getCurrentTimeZone
@@ -60,14 +60,18 @@ hoursToTimeZone i = minutesToTimeZone (60 * i)
showT :: PadOption -> Int -> String
showT opt t = showPaddedNum opt ((div t 60) * 100 + (mod t 60))
+timeZoneOffsetString'' :: PadOption -> TimeZone -> String
+timeZoneOffsetString'' opt (TimeZone t _ _) | t < 0 = '-':(showT opt (negate t))
+timeZoneOffsetString'' opt (TimeZone t _ _) = '+':(showT opt t)
+
-- | Text representing the offset of this timezone, such as \"-0800\" or \"+0400\" (like @%z@ in formatTime), with arbitrary padding.
-timeZoneOffsetString' :: PadOption -> TimeZone -> String
-timeZoneOffsetString' opt (TimeZone t _ _) | t < 0 = '-':(showT opt (negate t))
-timeZoneOffsetString' opt (TimeZone t _ _) = '+':(showT opt t)
+timeZoneOffsetString' :: Maybe Char -> TimeZone -> String
+timeZoneOffsetString' Nothing = timeZoneOffsetString'' NoPad
+timeZoneOffsetString' (Just c) = timeZoneOffsetString'' $ Pad 4 c
-- | Text representing the offset of this timezone, such as \"-0800\" or \"+0400\" (like @%z@ in formatTime).
timeZoneOffsetString :: TimeZone -> String
-timeZoneOffsetString = timeZoneOffsetString' (Pad 4 '0')
+timeZoneOffsetString = timeZoneOffsetString'' (Pad 4 '0')
instance Show TimeZone where
show zone@(TimeZone _ _ "") = timeZoneOffsetString zone
More information about the ghc-commits
mailing list