bd50838bb519eba42d049e80740ec498307fc43e
[ghc-hetmet.git] / ghc / misc / examples / io / io019 / Main.hs
1 import Time
2
3 main = 
4     getClockTime >>= \ time ->
5     print   time >>
6
7     let (CalendarTime year month mday hour min sec psec 
8                       wday yday timezone gmtoff isdst) = toUTCTime time
9     in
10       putStr (wdays !! wday) >>
11       putStr (' ' : months !! month) >>
12       putStr (' ' : shows2 mday (' ' : shows2 hour (':' : shows2 min (':' : shows2 sec
13              (' ' : timezone ++ ' ' : shows year "\n")))))
14
15   where
16     wdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
17     months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", 
18               "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
19     shows2 x = showString (pad2 x)
20     pad2 x = case show x of
21                c@[_] -> '0' : c
22                cs -> cs