Method: DateTime#to_date

Defined in:
ext/date/date_core.c

#to_dateObject

Returns a Date object which denotes self.



8865
8866
8867
8868
8869
8870
8871
8872
8873
8874
8875
8876
8877
8878
8879
8880
8881
8882
8883
8884
8885
8886
8887
8888
8889
# File 'ext/date/date_core.c', line 8865

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