module TinyScheduler.Jobs
( Job(..)
, makeJob
, timeAtomToJob
) where
import Data.Time
import Prelude hiding (id)
import TinyScheduler.Time
import TinyScheduler.TimeAtom
import TinyScheduler.Utils (calculateDelay)
data Job a = Job
{ id :: Int
, delay :: UTCTime -> [Int]
, job :: IO a
}
timeAtomToJob :: Int -> IO a -> UTCTime -> TimeAtom -> Job a
timeAtomToJob id job start atom = Job {id = id, delay = (delay_ atom start), job = job}
makeJob :: Int -> Int -> Interval -> UTCTime -> IO a -> Job a
makeJob id hits interval startTime job = Job id (calculateDelay interval hits startTime) job