Method: Time#+

Defined in:
time.c

#+(numeric) ⇒ Time

Returns a new Time object whose value is the sum of the numeric value of self and the given numeric:

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#-.

Returns:

[View source]

4465
4466
4467
4468
4469
4470
4471
4472
4473
4474
4475
# File 'time.c', line 4465

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);
}