Method: DateTime#to_date

Defined in:
ext/date/date_core.c

#to_dateObject

Returns a Date object which denotes self.



9074
9075
9076
9077
9078
9079
9080
9081
9082
9083
9084
9085
9086
9087
9088
9089
9090
9091
9092
9093
9094
9095
9096
9097
9098
# File 'ext/date/date_core.c', line 9074

static VALUE
datetime_to_date(VALUE self)
{
    get_d1a(self);

    if (simple_dat_p(adat)) {
  VALUE new = d_lite_s_alloc_simple(cDate);
  {
      get_d1b(new);
      bdat->s = adat->s;
      bdat->s.jd = m_local_jd(adat);
      return new;
  }
    }
    else {
  VALUE new = d_lite_s_alloc_simple(cDate);
  {
      get_d1b(new);
      copy_complex_to_simple(new, &bdat->s, &adat->c);
      bdat->s.jd = m_local_jd(adat);
      bdat->s.flags &= ~(HAVE_DF | HAVE_TIME | COMPLEX_DAT);
      return new;
  }
    }
}