R
rpardee
Hey All,
I'd like to run some code repeatedly, for 2 hours and then stop. I
figured I'd do this:
start_time = DateTime.now
two_hours = 2/24 # <--- This evaluates to 0?
finish_time = start_time + two_hours
until DateTime.now >= finish_time
# do some stuff
end
But it seems that 2 divided by 24 (which is what I intend by '2/24') is
evaluating to zero, so my code never runs. What am I missing?
BTW--I was disappointed not to find an add_hours() method on DateTime.
Did I just miss it, or is it really not there?
Thanks!
-Roy
I'd like to run some code repeatedly, for 2 hours and then stop. I
figured I'd do this:
start_time = DateTime.now
two_hours = 2/24 # <--- This evaluates to 0?
finish_time = start_time + two_hours
until DateTime.now >= finish_time
# do some stuff
end
But it seems that 2 divided by 24 (which is what I intend by '2/24') is
evaluating to zero, so my code never runs. What am I missing?
BTW--I was disappointed not to find an add_hours() method on DateTime.
Did I just miss it, or is it really not there?
Thanks!
-Roy