Skip to main content Link Search Menu Expand Document (external link)

between

Only runs the rule if the current time is in the provided range, between supports both time of day checks and month day checks.

Time of Day

rule 'Log an entry if started between 3:30:04 and midnight using strings' do
  on_start
  run { logger.info ("Started at #{TimeOfDay.now}")}
  between '3:30:04'..MIDNIGHT
end

or

rule 'Log an entry if started between 3:30:04 and midnight using TimeOfDay objects' do
  on_start
  run { logger.info ("Started at #{TimeOfDay.now}")}
  between TimeOfDay.new(h: 3, m: 30, s: 4)..MIDNIGHT
end

Month Day

rule 'Log an entry if started between March 9th and April 10ths' do
  on_start
  run { logger.info ("Started at #{Time.now}")}
  between '03-09'..'04-10'
end
rule 'Log an entry if started between March 9th and April 10ths' do
  on_start
  run { logger.info ("Started at #{Time.now}")}
  between MonthDay.of(03,09)..'04-06'
end