maennchen / crontab

Parse Cron Expressions, Compose Cron Expression Strings and Caluclate Execution Dates.
https://hex.pm/packages/crontab
MIT License
91 stars 32 forks source link

Can cron expression can be checked against current datetime? #85

Closed siddhant3030 closed 2 years ago

siddhant3030 commented 2 years ago

Hi,

I have a question. I have defined a bunch of cron_expression. I want to check if the current time is valid against the cron_expression.

So I first parse it cron_expression = Parser.parse!("0 * * * * MON,SAT *", true)

and then I'm trying to match it with this DateTime

a = ~N[2021-09-18 00:00:00] DateChecker.matches_date?(cron_expression, datetime)

this gave me true

and when I checked it against this current datetime ~N[2021-09-18 14:14:28.919029]

it gave me false. So in order to check this against a current datetime do we need to run cron jobs?