instance method
Date#to_time
() -> ::Time
to_time → time
ext/date/date_core.c
View on GitHub ↗
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;
}
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:
Example
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