Maintenance Ruby 3.3 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Date#to_time
to_time → time
ext/date/date_core.c
View on GitHub ↗
static VALUE
date_to_time(VALUE self)
{
get_d1a(self);
if (m_julian_p(adat)) {
VALUE tmp = d_lite_gregorian(self);
get_d1b(tmp);
adat = bdat;
}
return f_local3(rb_cTime,
m_real_year(adat),
INT2FIX(m_mon(adat)),
INT2FIX(m_mday(adat)));
}
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