localtime()
public
Show source
/*
* call-seq:
* time.localtime => time
*
* Converts <i>time</i> to local time (using the local time zone in
* effect for this process) modifying the receiver.
*
* t = Time.gm(2000, "jan", 1, 20, 15, 1)
* t.gmt?
* t.localtime
* t.gmt?
*/
static VALUE
time_localtime(time)
VALUE time;
{
struct time_object *tobj;
struct tm *tm_tmp;
time_t t;
GetTimeval(time, tobj);
if (!tobj->gmt) {
if (tobj->tm_got)
return time;
}
else {
time_modify(time);
}
t = tobj->tv.tv_sec;
tm_tmp = localtime(&t);
if (!tm_tmp)
rb_raise(rb_eArgError, "localtime error");
tobj->tm = *tm_tmp;
tobj->tm_got = 1;
tobj->gmt = 0;
return time;
}