Created
May 28, 2012 15:27
-
-
Save clockfort/2819739 to your computer and use it in GitHub Desktop.
xkcd calendar calculator
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = daysPerXKCDYear `div` 28 | |
solsticesAndEquinoxesPerYear = 4 | |
nonPrimeMinutesPerHour = ( 60 - length [x|x<-[0..59], isPrime x] ) | |
xkcdYearSeconds = year - 8*60*fullMoonsPerYear + 60*solsticesAndEquinoxesPerYear*2*nonPrimeMinutesPerHour | |
julianYearSeconds :: Int | |
julianYearSeconds = 31557600 --as per SI | |
delta = julianYearSeconds - xkcdYearSeconds | |
main = print $ "xkcd years are shorter by " ++ show delta ++ " seconds." | |
-- Sample output: "xkcd years are shorter by 352320 seconds." |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment