[project @ 1996-01-08 20:28:12 by partain]
[ghc-hetmet.git] / ghc / misc / examples / io / io019 / Main.hs
diff --git a/ghc/misc/examples/io/io019/Main.hs b/ghc/misc/examples/io/io019/Main.hs
new file mode 100644 (file)
index 0000000..168a4ac
--- /dev/null
@@ -0,0 +1,23 @@
+import LibTime
+
+main = 
+    getClockTime >>= \ time ->
+    putText time >>
+    putChar '\n' >>
+
+    let (CalendarTime year month mday hour min sec psec 
+                      wday yday timezone gmtoff isdst) = toUTCTime time
+    in
+      putStr (wdays !! wday) >>
+      putStr (' ' : months !! month) >>
+      putStr (' ' : shows2 mday (' ' : shows2 hour (':' : shows2 min (':' : shows2 sec
+             (' ' : timezone ++ ' ' : shows year "\n")))))
+
+  where
+    wdays = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]
+    months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", 
+             "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]
+    shows2 x = showString (pad2 x)
+    pad2 x = case show x of
+               c@[_] -> '0' : c
+               cs -> cs
\ No newline at end of file