Method: Time#tv_sec
- Defined in:
- time.c
permalink #to_i ⇒ Integer
Returns the value of self
as integer Epoch seconds; subseconds are truncated (not rounded):
Time.utc(1970, 1, 1, 0, 0, 0).to_i # => 0
Time.utc(1970, 1, 1, 0, 0, 0, 999999).to_i # => 0
Time.utc(1950, 1, 1, 0, 0, 0).to_i # => -631152000
Time.utc(1990, 1, 1, 0, 0, 0).to_i # => 631152000
Related: Time#to_f Time#to_r.
3793 3794 3795 3796 3797 3798 3799 3800 |
# File 'time.c', line 3793
static VALUE
time_to_i(VALUE time)
{
struct time_object *tobj;
GetTimeval(time, tobj);
return w2v(wdiv(tobj->timew, WINT2FIXWV(TIME_SCALE)));
}
|