1 -----------------------------------------------------------------------------
3 -- Module : System.Locale
4 -- Copyright : (c) The University of Glasgow 2001
5 -- License : BSD-style (see the file libraries/base/LICENSE)
7 -- Maintainer : libraries@haskell.org
8 -- Stability : provisional
9 -- Portability : portable
11 -- Operations for defining locale-specific date and time formats.
13 -----------------------------------------------------------------------------
26 data TimeLocale = TimeLocale {
27 wDays :: [(String, String)], -- full and abbreviated week days
28 months :: [(String, String)], -- full and abbreviated months
29 intervals :: [(String, String)],
30 amPm :: (String, String), -- AM/PM symbols
31 dateTimeFmt, dateFmt, -- formatting strings
32 timeFmt, time12Fmt :: String
33 } deriving (Eq, Ord, Show)
35 defaultTimeLocale :: TimeLocale
36 defaultTimeLocale = TimeLocale {
37 wDays = [("Sunday", "Sun"), ("Monday", "Mon"),
38 ("Tuesday", "Tue"), ("Wednesday", "Wed"),
39 ("Thursday", "Thu"), ("Friday", "Fri"),
42 months = [("January", "Jan"), ("February", "Feb"),
43 ("March", "Mar"), ("April", "Apr"),
44 ("May", "May"), ("June", "Jun"),
45 ("July", "Jul"), ("August", "Aug"),
46 ("September", "Sep"), ("October", "Oct"),
47 ("November", "Nov"), ("December", "Dec")],
49 intervals = [ ("year","years")
59 dateTimeFmt = "%a %b %e %H:%M:%S %Z %Y",
62 time12Fmt = "%I:%M:%S %p"
66 iso8601DateFormat :: Maybe String -> String
67 iso8601DateFormat timeFmt =
68 "%Y-%m-%d" ++ case timeFmt of
69 Nothing -> "" -- normally, ISO-8601 just defines YYYY-MM-DD
70 Just fmt -> ' ' : fmt -- but we can add a time spec
73 rfc822DateFormat :: String
74 rfc822DateFormat = "%a, %_d %b %Y %H:%M:%S %Z"