Skip to content

Instantly share code, notes, and snippets.

@ljsc
Created August 10, 2013 13:40
Show Gist options
  • Save ljsc/6200472 to your computer and use it in GitHub Desktop.
Save ljsc/6200472 to your computer and use it in GitHub Desktop.
Messing around with the haskell thyme package.
import Data.Thyme hiding (seconds)
import Data.Thyme.Format.Human
import Data.AffineSpace
import Data.VectorSpace
seconds, minutes, hours, days, weeks :: Rational -> NominalDiffTime
seconds n = fromSeconds n
minutes n = n *^ 60 *^ seconds 1
hours n = n *^ 60 *^ minutes 1
days n = n *^ 24 *^ hours 1
weeks n = n *^ 7 *^ days 1
now, xmas, dec, t0, helio :: UTCTime
now = read "2013-08-10 08:52:13 EST"
xmas = read "2013-12-25 06:00:00 EST"
dec = read "2010-01-01 00:00:00 EST"
t0 = read "1977-09-05 12:56:00 UTC"
helio = read "2012-08-25 00:00:00 UTC"
announce str d = putStrLn $ "Time to " ++ str ++ ": " ++ humanTimeDiff d
main = do
announce "leave the solar system" $ helio .-. t0
announce "wait for presents" $ xmas .-. now
print . toSeconds $ (helio .-. t0) ^/ toSeconds (xmas .-. now)
print (now .+^ weeks 3 .+^ days 2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment