at(...)
public
Creates a new time object with the value
given by aTime, or the given number of
seconds (and optional microseconds) from epoch. A
non-portable feature allows the offset to be negative on some systems.
Time.at(0)
Time.at(946702800)
Time.at(-284061600)
Show source
/*
* call-seq:
* Time.at( aTime ) => time
* Time.at( seconds [, microseconds] ) => time
*
* Creates a new time object with the value given by <i>aTime</i>, or
* the given number of <i>seconds</i> (and optional
* <i>microseconds</i>) from epoch. A non-portable feature allows the
* offset to be negative on some systems.
*
* Time.at(0)
* Time.at(946702800)
* Time.at(-284061600)
*/
static VALUE
time_s_at(argc, argv, klass)
int argc;
VALUE *argv;
VALUE klass;
{
struct timeval tv;
VALUE time, t;
if (rb_scan_args(argc, argv, "11", &time, &t) == 2) {
tv.tv_sec = NUM2LONG(time);
tv.tv_usec = NUM2LONG(t);
}
else {
tv = rb_time_timeval(time);
}
t = time_new_internal(klass, tv.tv_sec, tv.tv_usec);
if (TYPE(time) == T_DATA && RDATA(time)->dfree == time_free) {
struct time_object *tobj, *tobj2;
GetTimeval(time, tobj);
GetTimeval(t, tobj2);
tobj2->gmt = tobj->gmt;
}
return t;
}