diff options
Diffstat (limited to 'src/server/MonthlyPaymentJob.hs')
-rw-r--r-- | src/server/MonthlyPaymentJob.hs | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/server/MonthlyPaymentJob.hs b/src/server/MonthlyPaymentJob.hs index 1b331af..f5f6878 100644 --- a/src/server/MonthlyPaymentJob.hs +++ b/src/server/MonthlyPaymentJob.hs @@ -5,8 +5,6 @@ module MonthlyPaymentJob import Control.Monad.IO.Class (liftIO) import Data.Time.Clock -import Data.Time.LocalTime -import Data.Time.Calendar import Database.Persist (entityVal, insert) @@ -17,6 +15,8 @@ import Model.Payment (getMonthlyPayments) import Model.JobKind import Model.Frequency +import Utils.Time (belongToCurrentMonth) + monthlyPaymentJobListener :: IO () monthlyPaymentJobListener = let lastExecutionTooOld = fmap not . belongToCurrentMonth @@ -24,18 +24,6 @@ monthlyPaymentJobListener = msDelay = 1000000 * 60 * 60 in jobListener MonthlyPaymentJob lastExecutionTooOld runJob msDelay -belongToCurrentMonth :: UTCTime -> IO Bool -belongToCurrentMonth time = do - month <- getLocalMonth time - actualMonth <- getCurrentTime >>= getLocalMonth - return (month == actualMonth) - -getLocalMonth :: UTCTime -> IO Int -getLocalMonth time = do - timeZone <- getCurrentTimeZone - let (_, month, _) = toGregorian . localDay $ utcToLocalTime timeZone time - return month - monthlyPaymentJob :: Persist () monthlyPaymentJob = do monthlyPayments <- map entityVal <$> getMonthlyPayments |