Method: Date#to_time

Defined in:
date_core.c

#to_timeTime

Returns a new Time object with the same value as self; if self is a Julian date, derives its Gregorian date for conversion to the Time object:

Date.new(2001, 2, 3).to_time               # => 2001-02-03 00:00:00 -0600
Date.new(2001, 2, 3, Date::JULIAN).to_time # => 2001-02-16 00:00:00 -0600

Returns:



8949
8950
8951
8952
8953
8954
8955
8956
8957
8958
8959
8960
8961
8962
8963
8964
8965
8966
8967
8968
8969
# File 'date_core.c', line 8949

static VALUE
date_to_time(VALUE self)
{
    VALUE t;

    get_d1a(self);

    if (m_julian_p(adat)) {
        VALUE g = d_lite_gregorian(self);
        get_d1b(g);
        adat = bdat;
        self = g;
    }

    t = f_local3(rb_cTime,
        m_real_year(adat),
        INT2FIX(m_mon(adat)),
        INT2FIX(m_mday(adat)));
    RB_GC_GUARD(self); /* may be the converted gregorian */
    return t;
}