Created
July 25, 2008 06:18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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