2 % (c) The GRASP/AQUA Project, Glasgow University, 1995-99
4 \section[Time]{Haskell 1.4 Locale Library}
17 import Prelude -- so as to force recompilations when reqd.
19 data TimeLocale = TimeLocale {
20 wDays :: [(String, String)], -- full and abbreviated week days
21 months :: [(String, String)], -- full and abbreviated months
22 intervals :: [(String, String)],
23 amPm :: (String, String), -- AM/PM symbols
24 dateTimeFmt, dateFmt, -- formatting strings
25 timeFmt, time12Fmt :: String
26 } deriving (Eq, Ord, Show)
28 defaultTimeLocale :: TimeLocale
29 defaultTimeLocale = TimeLocale {
30 wDays = [("Sunday", "Sun"), ("Monday", "Mon"),
31 ("Tuesday", "Tue"), ("Wednesday", "Wed"),
32 ("Thursday", "Thu"), ("Friday", "Fri"),
35 months = [("January", "Jan"), ("February", "Feb"),
36 ("March", "Mar"), ("April", "Apr"),
37 ("May", "May"), ("June", "Jun"),
38 ("July", "Jul"), ("August", "Aug"),
39 ("September", "Sep"), ("October", "Oct"),
40 ("November", "Nov"), ("December", "Dec")],
42 intervals = [ ("year","years")
52 dateTimeFmt = "%a %b %e %H:%M:%S %Z %Y",
55 time12Fmt = "%I:%M:%S %p"
59 iso8601DateFormat :: Maybe String -> String
60 iso8601DateFormat timeFmt =
61 "%Y-%m-%d" ++ case timeFmt of
62 Nothing -> "" -- normally, ISO-8601 just defines YYYY-MM-DD
63 Just fmt -> ' ' : fmt -- but we can add a time spec
66 rfc822DateFormat :: String
67 rfc822DateFormat = "%a, %_d %b %Y %H:%M:%S %Z"