instance method
Time#to_a
() -> [ ::Integer, ::Integer, ::Integer, ::Integer, ::Integer, ::Integer, ::Integer, ::Integer, bool, ::String? ]
to_a → array
time.c
View on GitHub ↗
static VALUE
time_to_a(VALUE time)
{
struct time_object *tobj;
GetTimeval(time, tobj);
MAKE_TM_ENSURE(time, tobj, tobj->vtm.yday != 0);
return rb_ary_new3(10,
INT2FIX(tobj->vtm.sec),
INT2FIX(tobj->vtm.min),
INT2FIX(tobj->vtm.hour),
INT2FIX(tobj->vtm.mday),
INT2FIX(tobj->vtm.mon),
tobj->vtm.year,
INT2FIX(tobj->vtm.wday),
INT2FIX(tobj->vtm.yday),
RBOOL(tobj->vtm.isdst),
time_zone(time));
}
Returns a 10-element array of values representing self:
Example
Time.utc(2000, 1, 1).to_a # => [0, 0, 0, 1, 1, 2000, 6, 1, false, "UTC"] # [sec, min, hour, day, mon, year, wday, yday, dst?, zone]
The returned array is suitable for use as an argument to Time.utc or Time.local to create a new Time object.