From 7177f951bd942ca7710b669e4b3f43e700d4f2fa Mon Sep 17 00:00:00 2001 From: Sean Whitton Date: Tue, 31 Mar 2015 18:29:05 +0900 Subject: fill out more of Main.hs --- src/Main.hs | 31 +++++++++++++++++++++++-------- src/Utility/Notify.hs | 6 ++++++ 2 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 src/Utility/Notify.hs diff --git a/src/Main.hs b/src/Main.hs index 446572f..fe11389 100644 --- a/src/Main.hs +++ b/src/Main.hs @@ -22,21 +22,34 @@ -} import Control.Applicative ((<$>), (<*>)) +import Control.Monad (mapM_) +import Data.List (intercalate) import Data.Time.Calendar import Data.Time.LocalTime import System.Environment (getArgs) +import Text.Regex.Posix ((=~)) import Types.Reminder import Utility.EventCache +import Utility.Notify -doCron :: IO () -doCron = do - rems <- (++) <$> readEmacsEventCache <*> readManualEventCache +doCron :: IO () +doCron = do + rems <- (++) <$> readEmacsEventCache <*> readManualEventCache (h, m, _) <- localHMD - let nowRems = filter undefined rems - undefined + let nowRemsFilter r = getReminderHour r == h + && getReminderMinute r == m + nowRems = filter nowRemsFilter rems + mapM_ sendNotification nowRems -cmdLineReminder :: [String] -> Maybe Reminder -cmdLineReminder args = undefined +cmdLineReminder :: [String] -> Maybe Reminder +cmdLineReminder [] = Nothing +cmdLineReminder [_] = Nothing +cmdLineReminder (exp:textParts) = do + undefined + where + text = intercalate " " textParts + relativeRegExp = "[0-9]+[mh]" + absoluteRegExp = "[0-9]{1,2}(:[0-9][0-9])?(am|pm)?" appendUserReminder :: Reminder -> IO () appendUserReminder r = do @@ -58,7 +71,9 @@ appendUserReminder r = do -- appointment in Emacs Org-mode should be used instead of srem's -- manual reminder input. let dummyRem = makeReminder' h m (getReminderText r) - undefined + if maybe False (r <=) dummyRem + then appendManualEventCache r (addDays 1 d) + else appendManualEventCache r d main = do args <- getArgs diff --git a/src/Utility/Notify.hs b/src/Utility/Notify.hs new file mode 100644 index 0000000..3912314 --- /dev/null +++ b/src/Utility/Notify.hs @@ -0,0 +1,6 @@ +module Utility.Notify (sendNotification) where + +import Types.Reminder + +sendNotification :: Reminder -> IO () +sendNotification r = undefined -- cgit v1.2.3