-
-
Save dysinger/750acc2daeaa4bbd9f9e0b9ebd9e8f8b to your computer and use it in GitHub Desktop.
Messing around with the haskell thyme package.
This file contains hidden or 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
#!/usr/bin/env stack | |
-- stack --resolver lts-6 --install-ghc runghc --package lens --package thyme --package vector-space | |
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