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 -----------------------------------------------------------------------------
15 module System.Locale (
17 -- |The 'Locale' library provides the ability to adapt to local conventions.
18 -- At present, it supports only time and date information as used by
19 -- 'calendarTimeToString' from the "System.Time" library.
32 data TimeLocale = TimeLocale {
33 -- |full and abbreviated week days
34 wDays :: [(String, String)],
35 -- |full and abbreviated months
36 months :: [(String, String)],
37 intervals :: [(String, String)],
39 amPm :: (String, String),
40 -- |formatting strings
42 timeFmt, time12Fmt :: String
43 } deriving (Eq, Ord, Show)
45 defaultTimeLocale :: TimeLocale
46 defaultTimeLocale = TimeLocale {
47 wDays = [("Sunday", "Sun"), ("Monday", "Mon"),
48 ("Tuesday", "Tue"), ("Wednesday", "Wed"),
49 ("Thursday", "Thu"), ("Friday", "Fri"),
52 months = [("January", "Jan"), ("February", "Feb"),
53 ("March", "Mar"), ("April", "Apr"),
54 ("May", "May"), ("June", "Jun"),
55 ("July", "Jul"), ("August", "Aug"),
56 ("September", "Sep"), ("October", "Oct"),
57 ("November", "Nov"), ("December", "Dec")],
59 intervals = [ ("year","years")
69 dateTimeFmt = "%a %b %e %H:%M:%S %Z %Y",
72 time12Fmt = "%I:%M:%S %p"
76 -- |Normally, ISO-8601 just defines YYYY-MM-DD
77 -- but we can add a time spec.
79 iso8601DateFormat :: Maybe String -> String
80 iso8601DateFormat timeFmt =
81 "%Y-%m-%d" ++ case timeFmt of
86 rfc822DateFormat :: String
87 rfc822DateFormat = "%a, %_d %b %Y %H:%M:%S %Z"