End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Time#+
self + numeric → new_time
time.c
View on GitHub ↗
static VALUE
time_plus(VALUE time1, VALUE time2)
{
struct time_object *tobj;
GetTimeval(time1, tobj);
if (IsTimeval(time2)) {
rb_raise(rb_eTypeError, "time + time?");
}
return time_add(tobj, time1, time2, 1);
}
Returns a new Time object whose value is the sum of the numeric value of self and the given numeric:
Example
t = Time.new(2000) # => 2000-01-01 00:00:00 -0600 t + (60 * 60 * 24) # => 2000-01-02 00:00:00 -0600 t + 0.5 # => 2000-01-01 00:00:00.5 -0600
Related: Time#-.