PageRenderTime 29ms CodeModel.GetById 13ms app.highlight 3ms RepoModel.GetById 6ms app.codeStats 0ms

/test/TestMonthDay.hs

http://github.com/takano-akio/time
Haskell | 20 lines | 15 code | 4 blank | 1 comment | 3 complexity | 14259e6d218807c16ae7ccf638261016 MD5 | raw file
Possible License(s): BSD-3-Clause
 1{-# OPTIONS -Wall -Werror #-}
 2
 3module Main where
 4
 5import Data.Time.Calendar.MonthDay
 6
 7showCompare :: (Eq a,Show a) => a -> String -> a -> String
 8showCompare a1 b a2 | a1 == a2 = (show a1) ++ " == " ++ b
 9showCompare a1 b a2 = "DIFF: " ++ (show a1) ++ " -> " ++ b ++ " -> " ++ (show a2)
10
11main :: IO ()
12main = mapM_ (\isLeap -> do
13	putStrLn (if isLeap then "Leap:" else "Regular:")
14	mapM_ (\yd -> do
15		let (m,d) = dayOfYearToMonthAndDay isLeap yd
16		let yd' = monthAndDayToDayOfYear isLeap m d
17		let mdtext = (show m) ++ "-" ++ (show d)
18		putStrLn (showCompare yd mdtext yd')
19		) [-2..369]
20	) [False,True]