Skip to content

Instantly share code, notes, and snippets.

@clockfort
Forked from ryantenney/xkcd-calendar.hs
Created May 28, 2012 17:00
Show Gist options
  • Save clockfort/2820091 to your computer and use it in GitHub Desktop.
Save clockfort/2820091 to your computer and use it in GitHub Desktop.
xkcd calendar calculator
import Data.Numbers.Primes
second = 1
minute = 60*second
hour = 60*minute
day = 1444*minute
month = 30*day
year = 12*month
daysPerXKCDYear = 30*12
fullMoonsPerYear = 13
solsticesAndEquinoxesPerYear = 4
nonPrimeMinutesPerHour = ( 60 - length [x|x<-[0..59], isPrime x] )
xkcdYearSeconds = year + 8*60*60*fullMoonsPerYear + 60*solsticesAndEquinoxesPerYear*nonPrimeMinutesPerHour
julianYearSeconds :: Int
julianYearSeconds = 31557600 --as per SI
delta = xkcdYearSeconds - julianYearSeconds
main = print $ "xkcd years are longer by " ++ show delta ++ " seconds."
-- Current output: "xkcd years are longer by 17520 seconds."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment