summaryrefslogtreecommitdiffhomepage
path: root/src/Plugins/DateL.hs
diff options
context:
space:
mode:
authorMartin Perner <martin@perner.cc>2011-10-26 01:00:32 +0200
committerMartin Perner <martin@perner.cc>2011-10-26 02:01:05 +0200
commit9718dabe6c6d5979e3f6837ef04a39d3ad8c786c (patch)
treea4b13708063b856499989bd453d7c28a335b55e7 /src/Plugins/DateL.hs
parent218d07606a7564cdcde5974d53b8e81d04c02a44 (diff)
downloadxmobar-9718dabe6c6d5979e3f6837ef04a39d3ad8c786c.tar.gz
xmobar-9718dabe6c6d5979e3f6837ef04a39d3ad8c786c.tar.bz2
Adding locale support to Date plugins
This commits adds support for localized datetime outputs like date(1).
Diffstat (limited to 'src/Plugins/DateL.hs')
-rw-r--r--src/Plugins/DateL.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/Plugins/DateL.hs b/src/Plugins/DateL.hs
new file mode 100644
index 0000000..d8859ed
--- /dev/null
+++ b/src/Plugins/DateL.hs
@@ -0,0 +1,35 @@
+-----------------------------------------------------------------------------
+-- |
+-- Module : Plugins.DateL
+-- Copyright : (c) Andrea Rossato
+-- License : BSD-style (see LICENSE)
+--
+-- Maintainer : Martin Perner <martin@perner.cc>
+-- Stability : unstable
+-- Portability : unportable
+--
+-- A date plugin with localization for Xmobar
+--
+-----------------------------------------------------------------------------
+
+module Plugins.DateL (DateL(..)) where
+
+import Plugins
+import Localize
+
+import System.Time
+
+data DateL = DateL String String String Int
+ deriving (Read, Show)
+
+instance Exec DateL where
+ alias (DateL _ _ a _) = a
+ start (DateL f l _ r) cb = do
+ setupTimeLocale l
+ go
+ where go = date f >>= cb >> tenthSeconds r >> go
+
+date :: String -> IO String
+date format = do
+ t <- toCalendarTime =<< getClockTime
+ return $ formatCalendarTime getTimeLocale format t