Method: DateTime#to_date

Defined in:
ext/date/date_core.c

#to_dateObject

Returns a Date object which denotes self.



8941
8942
8943
8944
8945
8946
8947
8948
8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
# File 'ext/date/date_core.c', line 8941

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