Method: Time#to_f
- Defined in:
- time.c
#to_f ⇒ Float
Returns the value of time as a floating point number of seconds since the Epoch.
t = Time.now
"%10.5f" % t.to_f #=> "1270968744.77658"
t.to_i #=> 1270968744
Note that IEEE 754 double is not accurate enough to represent the number of nanoseconds since the Epoch.
3185 3186 3187 3188 3189 3190 3191 3192 |
# File 'time.c', line 3185 static VALUE time_to_f(VALUE time) { struct time_object *tobj; GetTimeval(time, tobj); return rb_Float(rb_time_unmagnify_to_float(tobj->timew)); } |