haskell-01-basic.hs 661 Bytes
Newer Older
epsi sayidina's avatar
epsi sayidina committed
1 2 3 4 5 6 7 8 9 10 11 12 13
import Data.Time.LocalTime
import Data.Time.Format

import Control.Concurrent
import Control.Monad

-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ---
-- wrap Funktion

myTimeFormat = "%a %b %d %H:%M:%S"

wFormatTime :: FormatTime t => t -> String
wFormatTime myUtcTime = formatTime 
epsi sayidina's avatar
epsi sayidina committed
14
    Data.Time.Format.defaultTimeLocale myTimeFormat myUtcTime
epsi sayidina's avatar
epsi sayidina committed
15 16

wSleep :: Int -> IO ()
epsi sayidina's avatar
epsi sayidina committed
17
wSleep mySecond = threadDelay (1000000 * mySecond)
epsi sayidina's avatar
epsi sayidina committed
18 19

printDate = do
epsi sayidina's avatar
epsi sayidina committed
20 21 22 23
    now <- getZonedTime
    let nowFmt = wFormatTime now
    putStrLn nowFmt
    wSleep 1
epsi sayidina's avatar
epsi sayidina committed
24 25 26 27 28 29 30

-- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ---
-- main

main = forever $ printDate