Remove Control.Parallel*, now in package parallel
[packages/random.git] / System / Locale.hs
1 -----------------------------------------------------------------------------
2 -- |
3 -- Module : System.Locale
4 -- Copyright : (c) The University of Glasgow 2001
5 -- License : BSD-style (see the file libraries/base/LICENSE)
6 --
7 -- Maintainer : libraries@haskell.org
8 -- Stability : stable
9 -- Portability : portable
10 --
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.
14 --
15 -----------------------------------------------------------------------------
16
17 module System.Locale (
18
19 TimeLocale(..)
20
21 , defaultTimeLocale
22
23 , iso8601DateFormat
24 , rfc822DateFormat
25 )
26 where
27
28 import Prelude
29
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)],
36 -- |AM\/PM symbols
37 amPm :: (String, String),
38 -- |formatting strings
39 dateTimeFmt, dateFmt,
40 timeFmt, time12Fmt :: String
41 } deriving (Eq, Ord, Show)
42
43 defaultTimeLocale :: TimeLocale
44 defaultTimeLocale = TimeLocale {
45 wDays = [("Sunday", "Sun"), ("Monday", "Mon"),
46 ("Tuesday", "Tue"), ("Wednesday", "Wed"),
47 ("Thursday", "Thu"), ("Friday", "Fri"),
48 ("Saturday", "Sat")],
49
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")],
56
57 intervals = [ ("year","years")
58 , ("month", "months")
59 , ("day","days")
60 , ("hour","hours")
61 , ("min","mins")
62 , ("sec","secs")
63 , ("usec","usecs")
64 ],
65
66 amPm = ("AM", "PM"),
67 dateTimeFmt = "%a %b %e %H:%M:%S %Z %Y",
68 dateFmt = "%m/%d/%y",
69 timeFmt = "%H:%M:%S",
70 time12Fmt = "%I:%M:%S %p"
71 }
72
73
74 -- |Normally, ISO-8601 just defines YYYY-MM-DD
75 -- but we can add a time spec.
76
77 iso8601DateFormat :: Maybe String -> String
78 iso8601DateFormat timeFmt =
79 "%Y-%m-%d" ++ case timeFmt of
80 Nothing -> ""
81 Just fmt -> ' ' : fmt
82
83
84 rfc822DateFormat :: String
85 rfc822DateFormat = "%a, %_d %b %Y %H:%M:%S %Z"