rhuss/schedule-cron — pull request #1 by hfs (2013-12-23 19:58:22+00:00)
Title: Calculate the previous execution time

There's already an exposed internal method to calculate the next execution time of a cron job.

This patch adds a "mirrored" function to calculate the *previous* execution time, too.

This might be useful in two circumstances:
- A job with an irregular/complicated schedule needs to known when or
how long ago it was previously scheduled
- If you want to monitor externally whether a cron job was executed
successfully based on its results and you need to know when it was
supposed to run the last time

Unfortunately quite a lot of code had to be copied from `get_next_execution_time()` and slightly altered to step backwards in time.

Note that if a positive timeshift is used (with `set_timeshift()`), the "previous" run can be in the future, because of the way the timeshifting works: the timeshift is added to the reference time (or current) time and from there the previous run is searched.

I needed this function in a non-public project for monitoring purposes and wanted to share it with you. In case you find it out of scope for the module or that it duplicates too much code, please don’t worry to decline the pull request.