Fixes to schedule

Fixing an issue when using the "when" argument to the scheduler.
This was a bug that was introduced when the cron like support was added.
#15369