Use time instead of old-time and old-locale

Get rid of these deprecated libraries, as the new `time' library
provides a strict superset of the functionality of `old-time' and
`old-locale'.
This commit is contained in:
slotThe 2021-03-20 16:14:26 +01:00
parent f1bd315448
commit 94f1e943d4
3 changed files with 13 additions and 15 deletions

View File

@ -19,7 +19,8 @@ module XMonad.Actions.AfterDrag (
ifClick') where
import XMonad
import System.Time
import Data.Time (NominalDiffTime, diffUTCTime, getCurrentTime)
-- $usage
-- You can use this module with the following in your @~\/.xmonad\/xmonad.hs@:
@ -63,9 +64,9 @@ ifClick'
-> X () -- ^ The action to take if the dragging turned out to not be a click.
-> X ()
ifClick' ms click drag = do
start <- io $ getClockTime
start <- io getCurrentTime
afterDrag $ do
stop <- io $ getClockTime
if diffClockTimes stop start <= noTimeDiff { tdPicosec = fromIntegral ms * 10^(9 :: Integer) }
stop <- io getCurrentTime
if diffUTCTime stop start <= (fromIntegral ms / 10^(3 :: Integer) :: NominalDiffTime)
then click
else drag

View File

@ -57,11 +57,10 @@ import XMonad.Util.NamedWindows (getName)
import Control.Exception as E
import Data.List (find, isPrefixOf, isSuffixOf)
import Data.Maybe (fromMaybe)
import Data.Time (defaultTimeLocale, formatTime, getCurrentTime)
import System.Directory (getDirectoryContents)
import System.IO
import System.Locale
import System.IO (hGetLine)
import System.Process (runInteractiveCommand)
import System.Time
econst :: Monad m => a -> IOException -> m a
econst = const . return
@ -129,8 +128,7 @@ battery = logCmd "acpi | sed -r 's/.*?: (.*%).*/\\1/; s/[dD]ischarging, ([0-9]+%
-- For more information see something like
-- <http://www.cplusplus.com/reference/clibrary/ctime/strftime.html>.
date :: String -> Logger
date fmt = io $ do cal <- getClockTime >>= toCalendarTime
return . Just $ formatCalendarTime defaultTimeLocale fmt cal
date fmt = io $ Just . formatTime defaultTimeLocale fmt <$> getCurrentTime
-- | Get the load average. This assumes that you have a
-- utility called @uptime@ and that you have @sed@
@ -248,7 +246,7 @@ withScreen f n = do
ss <- withWindowSet $ return . W.screens
case find ((== n) . W.screen) ss of
Just s -> f s
Nothing -> pure $ Nothing
Nothing -> pure Nothing
-- $format
-- Combine logger formatting functions to make your

View File

@ -52,8 +52,7 @@ library
containers >= 0.5 && < 0.7,
directory,
filepath,
old-locale,
old-time,
time >= 1.8 && < 1.12,
process,
random,
mtl >= 1 && < 3,