Method: DateTime#next_day

Defined in:
ext/date_ext/datetime.c

#next_day(*args) ⇒ Object

next_day(n=1) -> DateTime

Returns a DateTime n days after the receiver. If n is negative, returns a DateTime before the receiver. The new DateTime is returned with the same fractional part and offset as the receiver.

DateTime.civil(2009, 1, 2, 12).next_day
# => #<DateTime 2009-01-03T12:00:00+00:00>
DateTime.civil(2009, 1, 2, 12).next_day(2)
# => #<DateTime 2009-01-04T12:00:00+00:00>


2387
2388
2389
2390
2391
2392
2393
2394
2395
2396
2397
2398
2399
2400
2401
2402
2403
# File 'ext/date_ext/datetime.c', line 2387

static VALUE rhrdt_next_day(int argc, VALUE *argv, VALUE self) {
  long i;

  switch(argc) {
    case 0:
      i = 1;
      break;
    case 1:
      i = NUM2LONG(argv[0]);
      break;
    default:
      rb_raise(rb_eArgError, "wrong number of arguments: %d for 1", argc);
      break;
  }

   return rhrdt__add_days(self, (double)i);
}