X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Flib%2Fstd%2FLocale.lhs;h=40a2e9f4f47c115b49a47cd627176e621cb230fc;hb=239e9471e104fd88ec93bf42623c3a68a496657a;hp=c76ee9f2ae07c42c78553a22b9e42856694ad22c;hpb=5dced8008782b056eb53de3a7cac5c64235faf44;p=ghc-hetmet.git diff --git a/ghc/lib/std/Locale.lhs b/ghc/lib/std/Locale.lhs index c76ee9f..40a2e9f 100644 --- a/ghc/lib/std/Locale.lhs +++ b/ghc/lib/std/Locale.lhs @@ -1,17 +1,28 @@ +% ----------------------------------------------------------------------------- +% $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 @@ -31,6 +42,15 @@ defaultTimeLocale = TimeLocale { ("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", @@ -38,4 +58,14 @@ defaultTimeLocale = TimeLocale { 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}