[commit: packages/time] ghc, master: fix format behaviour of %Q (c29513e)

git at git.haskell.org git at git.haskell.org
Wed Jul 19 22:05:45 UTC 2017


Repository : ssh://git@git.haskell.org/time

On branches: ghc,master
Link       : http://git.haskell.org/packages/time.git/commitdiff/c29513e6f79f6f8cefc69663c34e780570bef34a

>---------------------------------------------------------------

commit c29513e6f79f6f8cefc69663c34e780570bef34a
Author: Ashley Yakeley <ashley at yakeley.org>
Date:   Sat May 13 03:36:21 2017 -0700

    fix format behaviour of %Q


>---------------------------------------------------------------

c29513e6f79f6f8cefc69663c34e780570bef34a
 lib/Data/Time/Format.hs         | 4 +++-
 test/unix/Test/Format/Format.hs | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/lib/Data/Time/Format.hs b/lib/Data/Time/Format.hs
index bb03e24..efbb43f 100644
--- a/lib/Data/Time/Format.hs
+++ b/lib/Data/Time/Format.hs
@@ -275,7 +275,9 @@ instance FormatTime TimeOfDay where
     -- Second
     formatCharacter 'S' = Just $ padNum True  2 '0' $ (floor . todSec :: TimeOfDay -> Int)
     formatCharacter 'q' = Just $ padGeneral True True 12 '0' $ \_ pado -> showPaddedFixedFraction pado . todSec
-    formatCharacter 'Q' = Just $ padGeneral True False 12 '0' $ \_ pado -> ('.':) . showPaddedFixedFraction pado . todSec
+    formatCharacter 'Q' = Just $ padGeneral True False 12 '0' $ \_ pado -> dotNonEmpty . showPaddedFixedFraction pado . todSec where
+        dotNonEmpty "" = ""
+        dotNonEmpty s = '.':s
 
     -- Default
     formatCharacter _   = Nothing
diff --git a/test/unix/Test/Format/Format.hs b/test/unix/Test/Format/Format.hs
index fa7d5b8..7a816f0 100644
--- a/test/unix/Test/Format/Format.hs
+++ b/test/unix/Test/Format/Format.hs
@@ -190,13 +190,13 @@ testQs = [
     formatUnitTest "%-5q" 0 "     ",
     formatUnitTest "%-5q" 0.37 "37   ",
 
-    formatUnitTest "%Q" 0 ".",
+    formatUnitTest "%Q" 0 "",
     formatUnitTest "%Q" 0.37 ".37",
     formatUnitTest "%0Q" 0 ".000000000000",
     formatUnitTest "%0Q" 0.37 ".370000000000",
     formatUnitTest "%_Q" 0 ".            ",
     formatUnitTest "%_Q" 0.37 ".37          ",
-    formatUnitTest "%-Q" 0 ".",
+    formatUnitTest "%-Q" 0 "",
     formatUnitTest "%-Q" 0.37 ".37",
     formatUnitTest "%1Q" 0 ".0",
     formatUnitTest "%1Q" 0.37 ".3",



More information about the ghc-commits mailing list