+% -----------------------------------------------------------------------------
+% $Id: Locale.lhs,v 1.5 2000/06/30 13:39:35 simonmar Exp $
%
-% (c) The GRASP/AQUA Project, Glasgow University, 1995-97
+% (c) The University of Glasgow, 1995-2000
%
+
\section[Time]{Haskell 1.4 Locale Library}
\begin{code}
-module Locale(TimeLocale(..), defaultTimeLocale) where
+module Locale
+ ( TimeLocale(..)
+ , defaultTimeLocale
+
+ , iso8601DateFormat
+ , rfc822DateFormat
+ )
+where
import Prelude -- so as to force recompilations when reqd.
data TimeLocale = TimeLocale {
wDays :: [(String, String)], -- full and abbreviated week days
months :: [(String, String)], -- full and abbreviated months
+ intervals :: [(String, String)],
amPm :: (String, String), -- AM/PM symbols
dateTimeFmt, dateFmt, -- formatting strings
timeFmt, time12Fmt :: String
("September", "Sep"), ("October", "Oct"),
("November", "Nov"), ("December", "Dec")],
+ intervals = [ ("year","years")
+ , ("month", "months")
+ , ("day","days")
+ , ("hour","hours")
+ , ("min","mins")
+ , ("sec","secs")
+ , ("usec","usecs")
+ ],
+
amPm = ("AM", "PM"),
dateTimeFmt = "%a %b %e %H:%M:%S %Z %Y",
dateFmt = "%m/%d/%y",
time12Fmt = "%I:%M:%S %p"
}
+
+iso8601DateFormat :: Maybe String -> String
+iso8601DateFormat timeFmt =
+ "%Y-%m-%d" ++ case timeFmt of
+ Nothing -> "" -- normally, ISO-8601 just defines YYYY-MM-DD
+ Just fmt -> ' ' : fmt -- but we can add a time spec
+
+
+rfc822DateFormat :: String
+rfc822DateFormat = "%a, %_d %b %Y %H:%M:%S %Z"
\end{code}