[commit: packages/time] master: correct padding in parse; doc (83ec536)

git at git.haskell.org git at git.haskell.org
Sun Dec 20 07:53:33 UTC 2015


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

On branch  : master
Link       : http://git.haskell.org/packages/time.git/commitdiff/83ec536b75b3bd342ee273a7db061d35830afc32

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

commit 83ec536b75b3bd342ee273a7db061d35830afc32
Author: Ashley Yakeley <ashley at semantic.org>
Date:   Wed May 11 00:40:32 2011 -0700

    correct padding in parse; doc
    
    Ignore-this: b922ed3e94021edde3d9d78bdb9844b2
    
    darcs-hash:20110511074032-ac6dd-51fd06ffe64b8c2c3b836ebc511b990c1d9a0662


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

83ec536b75b3bd342ee273a7db061d35830afc32
 Data/Time/Format/Parse.hs | 19 ++++++++++---------
 1 file changed, 10 insertions(+), 9 deletions(-)

diff --git a/Data/Time/Format/Parse.hs b/Data/Time/Format/Parse.hs
index b8855c1..aaf7029 100644
--- a/Data/Time/Format/Parse.hs
+++ b/Data/Time/Format/Parse.hs
@@ -55,20 +55,21 @@ class ParseTime t where
     -- If the input does not include all the information needed to
     -- construct a complete value, any missing parts should be taken
     -- from 1970-01-01 00:00:00 +0000 (which was a Thursday).
+    -- In the absence of @%C@ or @%Y@, century is 1969 - 2068.
     buildTime :: TimeLocale -- ^ The time locale.
               -> [(Char,String)] -- ^ Pairs of format characters and the 
                                  -- corresponding part of the input.
               -> t
 
 #if LANGUAGE_Rank2Types
--- | Parses a time value given a format string. Supports the same %-codes as
--- 'formatTime'. Leading and trailing whitespace is accepted. Case is not
--- significant. Some variations in the input are accepted:
+-- | Parses a time value given a format string.
+-- Supports the same %-codes as 'formatTime', including @%-@, @%_@ and @%0@ modifiers.
+-- Leading and trailing whitespace is accepted. Case is not significant.
+-- Some variations in the input are accepted:
 --
 -- [@%z@] accepts any of @-HHMM@ or @-HH:MM at .
 --
--- [@%Z@] accepts any string of letters, or any
--- of the formats accepted by @%z at .
+-- [@%Z@] accepts any string of letters, or any of the formats accepted by @%z at .
 --
 parseTime :: ParseTime t =>
              TimeLocale -- ^ Time locale.
@@ -153,8 +154,8 @@ parseValue l mpad c =
       'p' -> oneOf (let (am,pm) = amPm l in [am, pm])
       'H' -> digits ZeroPadding 2
       'I' -> digits ZeroPadding 2
-      'k' -> digits NoPadding 2
-      'l' -> digits NoPadding 2
+      'k' -> digits SpacePadding 2
+      'l' -> digits SpacePadding 2
       'M' -> digits ZeroPadding 2 
       'S' -> digits ZeroPadding 2
       'q' -> digits ZeroPadding 12
@@ -168,7 +169,7 @@ parseValue l mpad c =
       'b' -> oneOf (map snd (months l))
       'm' -> digits ZeroPadding 2
       'd' -> digits ZeroPadding 2
-      'e' -> digits NoPadding 2
+      'e' -> digits SpacePadding 2
       'j' -> digits ZeroPadding 3
       'G' -> digits ZeroPadding 4
       'g' -> digits ZeroPadding 2
@@ -185,7 +186,7 @@ parseValue l mpad c =
     oneOf = choice . map string
     digitsforce ZeroPadding n = count n (satisfy isDigit)
     digitsforce SpacePadding n = skipSpaces >> oneUpTo n (satisfy isDigit)
-    digitsforce NoPadding n = skipSpaces >> oneUpTo n (satisfy isDigit)
+    digitsforce NoPadding n = oneUpTo n (satisfy isDigit)
     digits pad = digitsforce (fromMaybe pad mpad)
     oneUpTo :: Int -> ReadP a -> ReadP [a]
     oneUpTo 0 _ = pfail



More information about the ghc-commits mailing list