new()
public
Document-method: now
Synonym for Time.new. Returns a Time
object initialized tot he current system time.
Returns a Time object initialized to the current
system time. Note: The object created will be created using the
resolution available on your system clock, and so may include fractional
seconds.
a = Time.new
b = Time.new
a == b
"%.6f" % a.to_f
"%.6f" % b.to_f
Show source
/*
* 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
* b = Time.new
* a == b
* "%.6f" % a.to_f
* "%.6f" % b.to_f
*
*/
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;
}