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
9 -- Portability : portable
11 -- This module provides the ability to adapt to local conventions.
12 -- At present, it supports only time and date information as used by
13 -- 'System.Time.calendarTimeToString' from the "System.Time" module.
15 -----------------------------------------------------------------------------
17 module System.Locale (
30 data TimeLocale = TimeLocale {
31 -- |full and abbreviated week days
32 wDays :: [(String, String)],
33 -- |full and abbreviated months
34 months :: [(String, String)],
35 intervals :: [(String, String)],
37 amPm :: (String, String),
38 -- |formatting strings
40 timeFmt, time12Fmt :: String
41 } deriving (Eq, Ord, Show)
43 defaultTimeLocale :: TimeLocale
44 defaultTimeLocale = TimeLocale {
45 wDays = [("Sunday", "Sun"), ("Monday", "Mon"),
46 ("Tuesday", "Tue"), ("Wednesday", "Wed"),
47 ("Thursday", "Thu"), ("Friday", "Fri"),
50 months = [("January", "Jan"), ("February", "Feb"),
51 ("March", "Mar"), ("April", "Apr"),
52 ("May", "May"), ("June", "Jun"),
53 ("July", "Jul"), ("August", "Aug"),
54 ("September", "Sep"), ("October", "Oct"),
55 ("November", "Nov"), ("December", "Dec")],
57 intervals = [ ("year","years")
67 dateTimeFmt = "%a %b %e %H:%M:%S %Z %Y",
70 time12Fmt = "%I:%M:%S %p"
74 -- |Normally, ISO-8601 just defines YYYY-MM-DD
75 -- but we can add a time spec.
77 iso8601DateFormat :: Maybe String -> String
78 iso8601DateFormat timeFmt =
79 "%Y-%m-%d" ++ case timeFmt of
84 rfc822DateFormat :: String
85 rfc822DateFormat = "%a, %_d %b %Y %H:%M:%S %Z"