Skip to content

Instantly share code, notes, and snippets.

@Changaco
Forked from rolios/ListDaysOfMonth.hs
Last active August 29, 2015 13:57
Show Gist options
  • Save Changaco/9475376 to your computer and use it in GitHub Desktop.
Save Changaco/9475376 to your computer and use it in GitHub Desktop.
import Data.Time.Clock
import Data.Time.Calendar
currentDate :: IO (Integer, Int, Int)
currentDate = fmap (toGregorian . utctDay) getCurrentTime
daysOfMonth :: Integer -> Int -> [Day]
daysOfMonth year month = map (fromGregorian year month) [1..gregorianMonthLength year month]
main = do
(year, month, _) <- currentDate
let days = daysOfMonth year month
putStrLn $ "Days: " ++ (show $ length days)
mapM_ print days
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment