{-# LANGUAGE CPP #-}
module Xmobar.Plugins.Date (Date(..)) where
import Xmobar.Run.Exec
#if ! MIN_VERSION_time(1,5,0)
import System.Locale
#endif
import Data.Time
data Date = Date String String Int
deriving (ReadPrec [Date]
ReadPrec Date
Int -> ReadS Date
ReadS [Date]
(Int -> ReadS Date)
-> ReadS [Date] -> ReadPrec Date -> ReadPrec [Date] -> Read Date
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [Date]
$creadListPrec :: ReadPrec [Date]
readPrec :: ReadPrec Date
$creadPrec :: ReadPrec Date
readList :: ReadS [Date]
$creadList :: ReadS [Date]
readsPrec :: Int -> ReadS Date
$creadsPrec :: Int -> ReadS Date
Read, Int -> Date -> ShowS
[Date] -> ShowS
Date -> String
(Int -> Date -> ShowS)
-> (Date -> String) -> ([Date] -> ShowS) -> Show Date
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [Date] -> ShowS
$cshowList :: [Date] -> ShowS
show :: Date -> String
$cshow :: Date -> String
showsPrec :: Int -> Date -> ShowS
$cshowsPrec :: Int -> Date -> ShowS
Show)
instance Exec Date where
alias :: Date -> String
alias (Date String
_ String
a Int
_) = String
a
run :: Date -> IO String
run (Date String
f String
_ Int
_) = String -> IO String
date String
f
rate :: Date -> Int
rate (Date String
_ String
_ Int
r) = Int
r
date :: String -> IO String
date :: String -> IO String
date String
format = (ZonedTime -> String) -> IO ZonedTime -> IO String
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
fmap (TimeLocale -> String -> ZonedTime -> String
forall t. FormatTime t => TimeLocale -> String -> t -> String
formatTime TimeLocale
defaultTimeLocale String
format) IO ZonedTime
getZonedTime