pycron icon indicating copy to clipboard operation
pycron copied to clipboard

time of next true condition

Open kklmn opened this issue 6 years ago • 2 comments

Hello,

Given a cron-style string, can pycron give the future closest time it will be true?

Thanks!

kklmn avatar Aug 31 '19 19:08 kklmn

Hey, this should be fairly easy to implement with a similar structure as pycron.has_been(), pull requests are welcome ;) https://github.com/kipe/pycron/blob/master/pycron/init.py#L112

It would require some kind of "reasonable maximum iterations" though, so we wouldn't end up in an endless loop. Something like pycron.next(s, dt=None), if dt is None: dt = now() + timedelta(days=365) or so...

kipe avatar Oct 01 '19 15:10 kipe

@kipe quick win but iterating over every step/minute dont look optimal, next and prev value should by calculated somehow not bruteforced.

Kub-AT avatar Apr 27 '20 17:04 Kub-AT