This gem provides Rufus::Scheduler::CronLine#occurrences method which returns potential trigger time within the [ time0, time1 ] span. (time0 exclusive, time1 inclusive)
I tried to use Rufus::Scheduler#occurrences but it depends on machine time. It returns nothing on past time. This gem is machine-time independent.
Add this line to your application's Gemfile:
gem 'rufus-scheduler-cronline-occurrences'
And then execute:
$ bundle
Or install it yourself as:
$ gem install rufus-scheduler-cronline-occurrences
Rufus::Scheduler.parse('*/2 * * * * *').occurrences(Time.parse('2014-07-31 00:00:00 +0900'), Time.parse('2014-07-31 00:00:10 +0900'))
=> [2014-07-31 00:00:02 +0900,
2014-07-31 00:00:04 +0900,
2014-07-31 00:00:06 +0900,
2014-07-31 00:00:08 +0900,
2014-07-31 00:00:10 +0900]
- Fork it ( https://github.com/knagano/rufus-scheduler-cronline-occurrences/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request