Permalink
Browse files

19 almost complete

  • Loading branch information...
1 parent 6b38dfc commit 0eeb0c99db9835fc3bf51f37898bdb5f443860fd Eric Wilson committed Jan 29, 2011
Showing with 10 additions and 1 deletion.
  1. +10 −1 019.hs
View
11 019.hs
@@ -31,6 +31,9 @@ daysInMonth date
epoch :: Date
epoch = Date 1900 1 1
+
+epochDayOfWeek :: Int
+epochDayOfWeek = 1
daysInPreviousYearsSinceEpoch :: Year -> Int
daysInPreviousYearsSinceEpoch currentYear = sum $ map daysInYear [year epoch..currentYear-1]
@@ -50,4 +53,10 @@ monthsInYears :: Year -> Year -> [Date]
monthsInYears start end = [ Date y m 1 | y <- [start..end], m<-[1..12] ]
mod7 :: Int -> Int
-mod7 n = mod n 7
+mod7 n = mod n 7
+
+dayOfWeek :: Date -> Int
+dayOfWeek date = mod7 $ epochDayOfWeek + daysSinceEpoch date
+
+isSunday :: Date -> Bool
+isSunday date = dayOfWeek date == 0

0 comments on commit 0eeb0c9

Please sign in to comment.