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