How can I shorten this (working) code to create future dates in ruby for use as params in URLs?
I'm doing:
require 'cgi'
require 'time'
now=Time.new()
now_year=now.strftime('%Y').to_i
now_month=now.strftime('%m').to_i
now_day=now.strftime('%d').to_i
now_hour=now.strftime('%H').to_i
start_hour=(now_hour + 1)
end_hour=(now_hour + 2)
start_datetime=Time.new(now_year, now_month, now_day, start_hour)
end_datetime=Time.new(now_year, now_month, now_day, end_hour)
starts=CGI.escape(start_datetime.utc.strftime("%Y-%m-%dT%H:%M:%S.%3NZ"))
ends=CGI.escape(end_datetime.utc.strftime("%Y-%m-%dT%H:%M:%S.%3NZ"))
and it works, but it seems long and clumsy. Is there an easier way?