summaryrefslogtreecommitdiffhomepage
path: root/src/Xmobar/Plugins/Date.hs
diff options
context:
space:
mode:
Diffstat (limited to 'src/Xmobar/Plugins/Date.hs')
-rw-r--r--src/Xmobar/Plugins/Date.hs14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/Xmobar/Plugins/Date.hs b/src/Xmobar/Plugins/Date.hs
index 1cb0596..83ca1c9 100644
--- a/src/Xmobar/Plugins/Date.hs
+++ b/src/Xmobar/Plugins/Date.hs
@@ -31,8 +31,16 @@ data Date = Date String String Int
instance Exec Date where
alias (Date _ a _) = a
- run (Date f _ _) = date f
rate (Date _ _ r) = r
+ start (Date f _ r) cb = do
+ t <- getCurrentTime
+ zone <- getTimeZone t
+ go zone
+ where
+ go zone = doEveryTenthSeconds r $ date zone f >>= cb
-date :: String -> IO String
-date format = fmap (formatTime defaultTimeLocale format) getZonedTime
+date :: TimeZone -> String -> IO String
+date timezone format = do
+ time <- getCurrentTime
+ let zonedTime = utcToZonedTime timezone time
+ pure $ formatTime defaultTimeLocale format zonedTime