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