8
I have a Time object T. What's a reasonable way to add N days to T?
The best I've come up with feels somewhat tortured:
require 'date'
def add_days(time, days)
time.to_date.next_day(days).to_time
end
P.S.: If you are in the US, a correct answer must satisfy:
add_days(Time.new(2013, 3, 10, 0), 1) == Time.new(2013, 3, 11, 0)
and if you are in the EU, a correct answer must satisfy:
add_days(Time.new(2013, 3, 31, 0), 1) == Time.new(2013, 4, 1, 0)
P.P.S: This is a Ruby question, not a Rails question.