[commit: packages/time] master, wip/travis: %C not restricted to two characters in format (295c172)

git at git.haskell.org git at git.haskell.org
Sat May 7 06:47:51 UTC 2016


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

On branches: master,wip/travis
Link       : http://git.haskell.org/packages/time.git/commitdiff/295c172ffdfd981375485387e3c1963d2544095a

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

commit 295c172ffdfd981375485387e3c1963d2544095a
Author: Ashley Yakeley <ashley at semantic.org>
Date:   Sun Oct 28 22:29:37 2012 -0700

    %C not restricted to two characters in format
    
    Ignore-this: dab171d022b83436dc3a0449525654e
    
    darcs-hash:20121029052937-ac6dd-916d8ce315605f9b428f32728e8da8007091ae27


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

295c172ffdfd981375485387e3c1963d2544095a
 Data/Time/Format.hs | 4 ++--
 Test/TestFormat.hs  | 5 ++++-
 2 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/Data/Time/Format.hs b/Data/Time/Format.hs
index 174bbea..926004b 100644
--- a/Data/Time/Format.hs
+++ b/Data/Time/Format.hs
@@ -113,7 +113,7 @@ formatChar c locale mpado t = case (formatCharacter c) of
 --
 -- [@%y@] last two digits of year, @00@ - @99@
 --
--- [@%C@] century (being the first two digits of the year), @00@ - @99@
+-- [@%C@] century
 --
 -- [@%B@] month name, long form ('fst' from 'months' @locale@), @January@ - @December@
 --
@@ -213,7 +213,7 @@ instance FormatTime Day where
 	-- Year Count
 	formatCharacter 'Y' = Just (\_ _ -> show . fst . toOrdinalDate)
 	formatCharacter 'y' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . mod100 . fst . toOrdinalDate)
-	formatCharacter 'C' = Just (\_ opt -> (show2 (fromMaybe (Just '0') opt)) . div100 . fst . toOrdinalDate)
+	formatCharacter 'C' = Just (\_ _ -> show . div100 . fst . toOrdinalDate)
 	-- Month of Year
 	formatCharacter 'B' = Just (\locale _ -> fst . (\(_,m,_) -> (months locale) !! (m - 1)) . toGregorian)
 	formatCharacter 'b' = Just (\locale _ -> snd . (\(_,m,_) -> (months locale) !! (m - 1)) . toGregorian)
diff --git a/Test/TestFormat.hs b/Test/TestFormat.hs
index 001de68..3aae5e5 100644
--- a/Test/TestFormat.hs
+++ b/Test/TestFormat.hs
@@ -68,9 +68,12 @@ getYearP3 year = localTimeToUTC utc (LocalTime (fromGregorian year 03 04) midnig
 getYearP4 :: Integer -> UTCTime
 getYearP4 year = localTimeToUTC utc (LocalTime (fromGregorian year 12 31) midnight)
 
+years :: [Integer]
+years = [999,1000,1899,1900,1901] ++ [1980..2000] ++ [9999,10000]
+
 times :: [UTCTime]
 times = [baseTime0] ++ (fmap getDay [0..23]) ++ (fmap getDay [0..100]) ++
-	(fmap getYearP1 [1980..2000]) ++ (fmap getYearP2 [1980..2000]) ++ (fmap getYearP3 [1980..2000]) ++ (fmap getYearP4 [1980..2000])
+	(fmap getYearP1 years) ++ (fmap getYearP2 years) ++ (fmap getYearP3 years) ++ (fmap getYearP4 years)
 
 compareFormat :: String -> (String -> String) -> String -> TimeZone -> UTCTime -> TestInstance
 compareFormat testname modUnix fmt zone time =



More information about the ghc-commits mailing list