Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import Data.Time.Clock
- import Data.Time.Calendar
- import Data.Time.LocalTime
- main = do
- putStrLn "Please enter your birthyear:"
- birthyearstring <- getLine
- let birthyear = read birthyearstring :: Integer
- putStrLn "For the right timeunit, enter the respective digit:"
- putStrLn "1: Years, 2: Days"
- timeunitchoice <- getLine
- let timeunit =
- if timeunitchoice == "1" then "year"
- else if timeunitchoice == "2" then "day"
- else "Clever ;)"
- now <- getCurrentTime
- timezone <- getCurrentTimeZone
- let zoneNow = utcToLocalTime timezone now
- let (year, month, day) = toGregorian $ localDay zoneNow
- let ageint =
- if timeunitchoice == "1" then year-birthyear
- else if timeunitchoice == "2" then (year-birthyear)*365
- else 0
- let age = show ageint
- putStrLn ("Yikes, your survived " ++ age ++ timeunit ++ " s!")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement