Skip to content

Instantly share code, notes, and snippets.

@masak
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masak/abc315b79968dea31096 to your computer and use it in GitHub Desktop.
Save masak/abc315b79968dea31096 to your computer and use it in GitHub Desktop.
Find all Fridays-the-13th in the years 2012..2017
import Control.Monad
import Data.Time.Calendar
import Data.Time.Calendar.WeekDate
main = do
forM_ [2012..2017] $ \year -> do
forM_ [1..12] $ \month -> do
let date = fromGregorian year month 13
let (_, _, weekDay) = toWeekDate date
when (weekDay == 5) (putStrLn . showGregorian $ date)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment