Fix formatting and errors
This commit is contained in:
25
app/Main.hs
25
app/Main.hs
@ -1,27 +1,22 @@
|
||||
module Main where
|
||||
|
||||
import System.Environment (getArgs)
|
||||
import System.Exit
|
||||
import Text.Parsec.Error (ParseError)
|
||||
module Main
|
||||
( main
|
||||
) where
|
||||
|
||||
import Data.Dates
|
||||
import Pattern
|
||||
import Pattern (match)
|
||||
import System.Environment (getArgs)
|
||||
import System.Exit
|
||||
|
||||
main :: IO ()
|
||||
main = do
|
||||
args <- getArgs
|
||||
dt <- getCurrentDateTime
|
||||
currentDateTime <- getCurrentDateTime
|
||||
exitWith $
|
||||
case processArgs args dt of
|
||||
case processArgs args currentDateTime of
|
||||
Just True -> ExitSuccess
|
||||
Just False -> ExitFailure 1
|
||||
Nothing -> ExitFailure 2
|
||||
|
||||
processArgs :: [String] -> DateTime -> Maybe Bool
|
||||
processArgs [ptn] dt = safeMatch ptn dt
|
||||
processArgs [ptn, time] dt = matchGivenTime ptn (parseDate dt time)
|
||||
processArgs _ _ = Nothing
|
||||
|
||||
matchGivenTime :: String -> Either ParseError DateTime -> Maybe Bool
|
||||
matchGivenTime _ (Left _) = Nothing
|
||||
matchGivenTime ptn (Right dt) = safeMatch ptn dt
|
||||
processArgs [ptn] dt = match ptn dt
|
||||
processArgs _ _ = Nothing
|
||||
|
Reference in New Issue
Block a user