[commit: packages/time] master: Allow a colon between the hours and minutes when parsing with %z and %Z. (e6e4837)

git at git.haskell.org git at git.haskell.org
Sun Dec 20 07:51:42 UTC 2015


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

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

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

commit e6e4837310610731a112dced280b3a14e9fe9e8b
Author: bjorn <bjorn at bringert.net>
Date:   Tue Oct 16 12:52:39 2007 -0700

    Allow a colon between the hours and minutes when parsing with %z and %Z.
    
    darcs-hash:20071016195239-6cdb2-17cf31be16d40e755740f2d3d264094be8e344a3


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

e6e4837310610731a112dced280b3a14e9fe9e8b
 Data/Time/Format/Parse.hs | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/Data/Time/Format/Parse.hs b/Data/Time/Format/Parse.hs
index bee16e8..7e4c319 100644
--- a/Data/Time/Format/Parse.hs
+++ b/Data/Time/Format/Parse.hs
@@ -110,9 +110,9 @@ parseInput l = liftM catMaybes . mapM p
 parseValue :: TimeLocale -> Char -> ReadP String
 parseValue l c = 
     case c of
-      'z' -> liftM2 (:) (choice [char '+', char '-']) (digits 4)
+      'z' -> numericTZ
       'Z' -> munch1 isUpper <++
-             liftM2 (:) (choice [char '+', char '-']) (digits 4) <++
+             numericTZ <++
              return "" -- produced by %Z for LocalTime
       'P' -> oneOf (let (am,pm) = amPm l 
                      in [map toLower am, map toLower pm])
@@ -154,8 +154,11 @@ parseValue l c =
     upTo :: Int -> ReadP a -> ReadP [a]
     upTo 0 _ = return []
     upTo n x = liftM2 (:) x (upTo (n-1) x) <++ return []
-
-
+    numericTZ = do s <- choice [char '+', char '-']
+                   h <- digits 2
+                   optional (char ':')
+                   m <- digits 2
+                   return (s:h++m)
 
 --
 -- * Instances for the time package types



More information about the ghc-commits mailing list