From 100f5aabb6172fa3a9dbcb9c31e78ba6e0430cb8 Mon Sep 17 00:00:00 2001 From: Yaroslav Halchenko Date: Mon, 13 Mar 2023 22:35:54 -0400 Subject: [PATCH] Typo: recurrance -> recurrence --- Assistant/WebApp/Configurators/Fsck.hs | 8 +-- Utility/Scheduled.hs | 50 +++++++++---------- Utility/Scheduled/QuickCheck.hs | 2 +- .../configurators/fsck/formcontent.hamlet | 2 +- 4 files changed, 31 insertions(+), 31 deletions(-) diff --git a/Assistant/WebApp/Configurators/Fsck.hs b/Assistant/WebApp/Configurators/Fsck.hs index ee6ab1d91b..e220d34b44 100644 --- a/Assistant/WebApp/Configurators/Fsck.hs +++ b/Assistant/WebApp/Configurators/Fsck.hs @@ -67,14 +67,14 @@ runFsckForm new activity = case activity of (reposRes, reposView) <- mreq (selectFieldList repolist) (bfs "") (Just ru) (durationRes, durationView) <- mreq intField (bfs "") (Just $ durationSeconds d `quot` 60 ) (timeRes, timeView) <- mreq (selectFieldList times) (bfs "") (Just t) - (recurranceRes, recurranceView) <- mreq (selectFieldList recurrances) (bfs "") (Just r) + (recurrenceRes, recurrenceView) <- mreq (selectFieldList recurrences) (bfs "") (Just r) let form = do webAppFormAuthToken $(widgetFile "configurators/fsck/formcontent") let formresult = mkFsck <$> pure u <*> reposRes - <*> (Schedule <$> recurranceRes <*> timeRes) + <*> (Schedule <$> recurrenceRes <*> timeRes) <*> (Duration <$> ((60 *) <$> durationRes)) return (formresult, form) where @@ -82,8 +82,8 @@ runFsckForm new activity = case activity of times = ensurevalue t (T.pack $ fromScheduledTime t) $ map (\x -> (T.pack $ fromScheduledTime x, x)) $ AnyTime : map (\h -> SpecificTime h 0) [0..23] - recurrances :: [(Text, Recurrance)] - recurrances = ensurevalue r (T.pack $ fromRecurrance r) $ + recurrences :: [(Text, Recurrence)] + recurrences = ensurevalue r (T.pack $ fromRecurrence r) $ [ ("every day", Daily) , ("every Sunday", Weekly $ Just 1) , ("every Monday", Weekly $ Just 2) diff --git a/Utility/Scheduled.hs b/Utility/Scheduled.hs index dfaeb7ff40..7dacdc7ec6 100644 --- a/Utility/Scheduled.hs +++ b/Utility/Scheduled.hs @@ -7,7 +7,7 @@ module Utility.Scheduled ( Schedule(..), - Recurrance(..), + Recurrence(..), ScheduledTime(..), NextTime(..), WeekDay, @@ -19,8 +19,8 @@ module Utility.Scheduled ( fromSchedule, fromScheduledTime, toScheduledTime, - fromRecurrance, - toRecurrance, + fromRecurrence, + toRecurrence, toSchedule, parseSchedule, prop_past_sane, @@ -44,15 +44,15 @@ import Control.Applicative import Prelude {- Some sort of scheduled event. -} -data Schedule = Schedule Recurrance ScheduledTime +data Schedule = Schedule Recurrence ScheduledTime deriving (Eq, Read, Show, Ord) -data Recurrance +data Recurrence = Daily | Weekly (Maybe WeekDay) | Monthly (Maybe MonthDay) | Yearly (Maybe YearDay) - | Divisible Int Recurrance + | Divisible Int Recurrence -- ^ Days, Weeks, or Months of the year evenly divisible by a number. -- (Divisible Year is years evenly divisible by a number.) deriving (Eq, Read, Show, Ord) @@ -89,7 +89,7 @@ nextTime schedule lasttime = do -- | Calculate the next time that fits a Schedule, based on the -- last time it occurred, and the current time. calcNextTime :: Schedule -> Maybe LocalTime -> LocalTime -> Maybe NextTime -calcNextTime schedule@(Schedule recurrance scheduledtime) lasttime currenttime +calcNextTime schedule@(Schedule recurrence scheduledtime) lasttime currenttime | scheduledtime == AnyTime = do next <- findfromtoday True return $ case next of @@ -97,7 +97,7 @@ calcNextTime schedule@(Schedule recurrance scheduledtime) lasttime currenttime NextTimeExactly t -> window (localDay t) (localDay t) | otherwise = NextTimeExactly . startTime <$> findfromtoday False where - findfromtoday anytime = findfrom recurrance afterday today + findfromtoday anytime = findfrom recurrence afterday today where today = localDay currenttime afterday = sameaslastrun || toolatetoday @@ -225,24 +225,24 @@ maxmnum = 12 maxwday :: Int maxwday = 7 -fromRecurrance :: Recurrance -> String -fromRecurrance (Divisible n r) = - fromRecurrance' (++ "s divisible by " ++ show n) r -fromRecurrance r = fromRecurrance' ("every " ++) r +fromRecurrence :: Recurrence -> String +fromRecurrence (Divisible n r) = + fromRecurrence' (++ "s divisible by " ++ show n) r +fromRecurrence r = fromRecurrence' ("every " ++) r -fromRecurrance' :: (String -> String) -> Recurrance -> String -fromRecurrance' a Daily = a "day" -fromRecurrance' a (Weekly n) = onday n (a "week") -fromRecurrance' a (Monthly n) = onday n (a "month") -fromRecurrance' a (Yearly n) = onday n (a "year") -fromRecurrance' a (Divisible _n r) = fromRecurrance' a r -- not used +fromRecurrence' :: (String -> String) -> Recurrence -> String +fromRecurrence' a Daily = a "day" +fromRecurrence' a (Weekly n) = onday n (a "week") +fromRecurrence' a (Monthly n) = onday n (a "month") +fromRecurrence' a (Yearly n) = onday n (a "year") +fromRecurrence' a (Divisible _n r) = fromRecurrence' a r -- not used onday :: Maybe Int -> String -> String onday (Just n) s = "on day " ++ show n ++ " of " ++ s onday Nothing s = s -toRecurrance :: String -> Maybe Recurrance -toRecurrance s = case words s of +toRecurrence :: String -> Maybe Recurrence +toRecurrence s = case words s of ("every":"day":[]) -> Just Daily ("on":"day":sd:"of":"every":something:[]) -> withday sd something ("every":something:[]) -> noday something @@ -316,8 +316,8 @@ toScheduledTime v = case words v of <*> if null m then Just 0 else readish m fromSchedule :: Schedule -> String -fromSchedule (Schedule recurrance scheduledtime) = unwords - [ fromRecurrance recurrance +fromSchedule (Schedule recurrence scheduledtime) = unwords + [ fromRecurrence recurrence , "at" , fromScheduledTime scheduledtime ] @@ -327,14 +327,14 @@ toSchedule = eitherToMaybe . parseSchedule parseSchedule :: String -> Either String Schedule parseSchedule s = do - r <- maybe (Left $ "bad recurrance: " ++ recurrance) Right - (toRecurrance recurrance) + r <- maybe (Left $ "bad recurrence: " ++ recurrence) Right + (toRecurrence recurrence) t <- maybe (Left $ "bad time of day: " ++ scheduledtime) Right (toScheduledTime scheduledtime) Right $ Schedule r t where (rws, tws) = separate (== "at") (words s) - recurrance = unwords rws + recurrence = unwords rws scheduledtime = unwords tws prop_past_sane :: Bool diff --git a/Utility/Scheduled/QuickCheck.hs b/Utility/Scheduled/QuickCheck.hs index 96ce046c30..c8d4955af7 100644 --- a/Utility/Scheduled/QuickCheck.hs +++ b/Utility/Scheduled/QuickCheck.hs @@ -26,7 +26,7 @@ instance Arbitrary ScheduledTime where <*> choose (1, 59) ] -instance Arbitrary Recurrance where +instance Arbitrary Recurrence where arbitrary = oneof [ pure Daily , Weekly <$> arbday diff --git a/templates/configurators/fsck/formcontent.hamlet b/templates/configurators/fsck/formcontent.hamlet index 6efa4f37ea..f1506946ec 100644 --- a/templates/configurators/fsck/formcontent.hamlet +++ b/templates/configurators/fsck/formcontent.hamlet @@ -7,7 +7,7 @@ ^{fvInput durationView} minutes #
\ - ^{fvInput recurranceView} # + ^{fvInput recurrenceView} # \ starting at ^{fvInput timeView} # $if new