End of Life Ruby 3.1 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Time#+
time + numeric → 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);
}
Adds some number of seconds (possibly including subsecond) to time and returns that value as a new Time object.
Example
t = Time.now #=> 2020-07-20 22:14:43.170490982 +0900 t + (60 * 60 * 24) #=> 2020-07-21 22:14:43.170490982 +0900