
On Thu, 17 Dec 2009 17:18:41 +0100,
thanks Magnus, great, works so far. I added to check that myDay have to be greater 0:
legalDate :: Date -> Bool legalDate (myDay, myMonth, myYear) = maybe False id $ do days <- lookup myMonth monthAndMaxDay return (not (myDay <= 0) && (myDay <= days))
Another thing is, that I have to check for leapYears. I have a function that checks if a year is a leap year
isLeapYear :: Int -> Bool isLeapYear year = mod year 4 == 0
That is not entirely correct; from package time: isLeapYear :: Integer -> Bool isLeapYear year = (mod year 4 == 0) && ((mod year 400 == 0) || not (mod year 100 == 0))
monthAndMaxDay has 30 days for February which have to be fix. So i have to check in legalDate if the year is a leap year. If so I have to check myDay in February for 29 days, otherwise for 28 days. How can I implement this to isLegalDate?
Use fromGregorianValid from package time. Regards, Henk-Jan van Tuyl -- http://Van.Tuyl.eu/ http://members.chello.nl/hjgtuyl/tourdemonad.html -- --