[commit: packages/time] format-widths: document formatting padding widths change (80ee35c)

git at git.haskell.org git at git.haskell.org
Mon Feb 20 21:20:49 UTC 2017


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

On branch  : format-widths
Link       : http://git.haskell.org/packages/time.git/commitdiff/80ee35cc0b49c78c8209b6f9aaa276c4255185ca

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

commit 80ee35cc0b49c78c8209b6f9aaa276c4255185ca
Author: Ashley Yakeley <ashley at yakeley.org>
Date:   Tue Feb 7 19:31:39 2017 -0800

    document formatting padding widths change


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

80ee35cc0b49c78c8209b6f9aaa276c4255185ca
 changelog.md                  | 1 +
 lib/Data/Time/Format.hs       | 7 ++++++-
 lib/Data/Time/Format/Parse.hs | 2 +-
 3 files changed, 8 insertions(+), 2 deletions(-)

diff --git a/changelog.md b/changelog.md
index 72f2ae6..3e03aca 100644
--- a/changelog.md
+++ b/changelog.md
@@ -2,6 +2,7 @@
 
 ## [1.8]
 - Added SystemTime
+- Data.Time.Format: allow padding widths in specifiers for formatting (but not parsing)
 
 ## [1.7.0.1]
 - Fix bounds issue in .cabal file
diff --git a/lib/Data/Time/Format.hs b/lib/Data/Time/Format.hs
index 2a4815b..1538d34 100644
--- a/lib/Data/Time/Format.hs
+++ b/lib/Data/Time/Format.hs
@@ -54,7 +54,6 @@ padString ff = padGeneral False 1 ' ' $ \locale pado -> showPadded pado . ff loc
 padNum :: (Show i,Ord i,Num i) => Bool -> Int -> Char -> (t -> i) -> (TimeLocale -> Maybe NumericPadOption -> Maybe Int -> t -> String)
 padNum fdef idef cdef ff = padGeneral fdef idef cdef $ \_ pado -> showPaddedNum pado . ff
 
-
 -- <http://www.opengroup.org/onlinepubs/007908799/xsh/strftime.html>
 class FormatTime t where
     formatCharacter :: Char -> Maybe (TimeLocale -> Maybe NumericPadOption -> Maybe Int -> t -> String)
@@ -89,6 +88,12 @@ formatChar c = case formatCharacter c of
 --
 -- [@%#z@] convert to lower case (consistently, unlike glibc)
 --
+-- Width digits can also be used after any modifiers and before the letter (here marked as @z@), for example:
+--
+-- [@%4z@] pad to 4 characters (with default padding character)
+--
+-- [@%_12z@] pad with spaces to 12 characters
+--
 -- For 'TimeZone' (and 'ZonedTime' and 'UTCTime'):
 --
 -- [@%z@] timezone offset in the format @-HHMM at .
diff --git a/lib/Data/Time/Format/Parse.hs b/lib/Data/Time/Format/Parse.hs
index 7715697..29f112e 100644
--- a/lib/Data/Time/Format/Parse.hs
+++ b/lib/Data/Time/Format/Parse.hs
@@ -76,7 +76,7 @@ class ParseTime t where
 
 #if LANGUAGE_Rank2Types
 -- | Parses a time value given a format string.
--- Supports the same %-codes as 'formatTime', including @%-@, @%_@ and @%0@ modifiers.
+-- Supports the same %-codes as 'formatTime', including @%-@, @%_@ and @%0@ modifiers, however padding widths are not supported.
 -- Case is not significant.
 -- Some variations in the input are accepted:
 --



More information about the ghc-commits mailing list