Maintenance Ruby 3.4 gets fixes, but no new features. Switch to Ruby 4.0 →
instance method
Time#nsec
() -> ::Integer
nsec → integer
time.c
View on GitHub ↗
static VALUE
time_nsec(VALUE time)
{
struct time_object *tobj;
GetTimeval(time, tobj);
return rb_to_int(w2v(wmulquoll(wmod(tobj->timew, WINT2WV(TIME_SCALE)), 1000000000, TIME_SCALE)));
}
Alias of #tv_nsec
Returns the number of nanoseconds in the subseconds part of self in the range (0..999_999_999); lower-order digits are truncated, not rounded:
Example
t = Time.now # => 2022-07-11 15:04:53.3219637 -0500 t.nsec # => 321963700
Related: Time#subsec (returns exact subseconds).