Method: Time#to_a
- Defined in:
- time.c
#to_a ⇒ Array
Returns a 10-element array of values representing self:
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.
5093 5094 5095 5096 5097 5098 5099 5100 5101 5102 5103 5104 5105 5106 5107 5108 5109 5110 5111 |
# File 'time.c', line 5093 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)); } |