Skip to content

Instantly share code, notes, and snippets.

@oliyoung
Created July 25, 2008 06:18
Show Gist options
  • Save oliyoung/2394 to your computer and use it in GitHub Desktop.
Save oliyoung/2394 to your computer and use it in GitHub Desktop.
class Date
def at_some_point(options = {})
start_hour = options[:between]
end_hour = options[:and]
if start_hour && end_hour
hours = rand(end_hour) + start_hour
else
hours = rand(24)
end
minutes = rand(60)
seconds = rand(60)
Time.mktime(year, month, day,
hours, minutes, seconds)
end
end
class Fixnum
def am
self
end
def pm
self + 12
end
end
Job.schedule task, :to_run =>
Date.today.at_some_point(
:between => 1.am, :and => 7.am
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment