pluralize 1.1 kilobytes etc

This commit is contained in:
Joey Hess 2013-07-19 14:05:27 -04:00
parent dcf74cf8a4
commit b8da297c77

View file

@ -118,7 +118,7 @@ roughSize units abbrev i
showUnit i' (Unit s a n) = let (num, decimal) = chop i' s in showUnit i' (Unit s a n) = let (num, decimal) = chop i' s in
show num ++ decimal ++ " " ++ show num ++ decimal ++ " " ++
(if abbrev then a else plural num n) (if abbrev then a else plural num decimal n)
chop :: Integer -> Integer -> (Integer, String) chop :: Integer -> Integer -> (Integer, String)
chop i' d = chop i' d =
@ -130,9 +130,9 @@ roughSize units abbrev i
then (num, "") then (num, "")
else (num, "." ++ ds') else (num, "." ++ ds')
plural n u plural num decimal n
| n == 1 = u | num == 1 && null decimal = n
| otherwise = u ++ "s" | otherwise = n ++ "s"
{- displays comparison of two sizes -} {- displays comparison of two sizes -}
compareSizes :: [Unit] -> Bool -> ByteSize -> ByteSize -> String compareSizes :: [Unit] -> Bool -> ByteSize -> ByteSize -> String