diff --git a/changelog.md b/changelog.md index 72f2ae6a9080ec5b1d2605836c94d991ed1da011..3e03aca518c98c9b7caf48210cc52cce2ad43764 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 2a4815bb95b40be161181455da3b18282a7ab5df..1538d3426b93866448c2764c9287e4a99a2e242c 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@. diff --git a/lib/Data/Time/Format/Parse.hs b/lib/Data/Time/Format/Parse.hs index 7715697cf3a18a08ed1f5437405ea23151cc7177..29f112efef0a85b19f78eaaf6a46ed6bd64f9d4d 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: --