Replace obsolete `defaultUserHooks` by `autoconfUserHooks`
[packages/old-time.git] / tests / time003.hs
1 import System.Time
2
3 main :: IO ()
4 main = do
5 time <- getClockTime
6 print (plausible (show time))
7 let (CalendarTime year month mday hour min sec psec
8 wday yday timezone gmtoff isdst) = toUTCTime time
9 time2 = wdays !! fromEnum wday ++
10 (' ' : months !! fromEnum month) ++
11 (' ' : shows2 mday (' ' : shows2 hour (':' : shows2 min (':' : shows2 sec
12 (' ' : timezone ++ ' ' : shows year "\n")))))
13 print (plausible time2)
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
23
24 plausible str = filter (== ':') str == "::"