[project @ 2001-05-21 15:25:24 by simonmar]
[ghc-hetmet.git] / ghc / tests / lib / TimeExts / timeexts001.hs
1 module Main(main) where
2
3 import Time
4 import TimeExts
5
6 start = toClockTime(
7    CalendarTime {
8       ctYear = 1973,
9       ctMonth = December,
10       ctDay = 31,
11       ctHour = 11,
12       ctMin = 43,
13       ctSec = 55,
14       ctPicosec = 123123123123,
15       ctWDay = Monday,
16       ctYDay = 0,
17       ctTZName = "UTC",
18       ctTZ = 0,
19       ctIsDST = False
20       })
21
22 pClock :: ClockTime -> IO()
23 pClock c = 
24    do
25       putStr(calendarTimeToString(toUTCTime c))
26       putStr "\n"
27
28 getDiff :: TimeAddable a => ClockTime -> a
29 getDiff now = diffClock now start
30
31 printSum :: TimeAddable a => a -> IO ()
32 printSum diff = 
33    let
34       sum = addClock start diff
35    in
36       pClock sum
37       
38 main =
39    do
40       -- now <- getClockTime
41         -- now fixed so we get reliable output (SDM)
42       let now = TOD 944662832 34398000000
43       putStr "Start: "
44       pClock start
45       putStr "End: "
46       pClock now
47       putStr "Whole Picos\n"
48       printSum((getDiff now)::DiffPico)
49       putStr "Whole Seconds\n"
50       printSum((getDiff now)::DiffPico)
51       putStr "Whole Minutes\n"
52       printSum((getDiff now)::DiffMinute)
53       putStr "Whole Hours\n"
54       printSum((getDiff now)::DiffHour)
55       putStr "Whole Days\n"
56       printSum((getDiff now)::DiffDay)
57       putStr "Whole Months\n"
58       printSum((getDiff now)::DiffMonth)
59       putStr "Whole Years\n"
60       printSum((getDiff now)::DiffYear)
61
62
63