/* * Document-method: now * * Synonym for <code>Time.new</code>. Returns a +Time+ object * initialized tot he current system time. * * call-seq: * Time.new -> time * * Returns a <code>Time</code> object initialized to the current system * time. <b>Note:</b> The object created will be created using the * resolution available on your system clock, and so may include * fractional seconds. * * a = Time.new #=> Wed Apr 09 08:56:03 CDT 2003 * b = Time.new #=> Wed Apr 09 08:56:03 CDT 2003 * a == b #=> false * "%.6f" % a.to_f #=> "1049896563.230740" * "%.6f" % b.to_f #=> "1049896563.231466" * */ static VALUE time_init(time) VALUE time; { struct time_object *tobj; time_modify(time); GetTimeval(time, tobj); tobj->tm_got=0; tobj->tv.tv_sec = 0; tobj->tv.tv_usec = 0; if (gettimeofday(&tobj->tv, 0) < 0) { rb_sys_fail("gettimeofday"); } return time; }