utc()
public
Show source
/*
* call-seq:
* time.gmtime => time
* time.utc => time
*
* Converts <i>time</i> to UTC (GMT), modifying the receiver.
*
* t = Time.now
* t.gmt?
* t.gmtime
* t.gmt?
*
* t = Time.now
* t.utc?
* t.utc
* t.utc?
*/
static VALUE
time_gmtime(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 = gmtime(&t);
if (!tm_tmp)
rb_raise(rb_eArgError, "gmtime error");
tobj->tm = *tm_tmp;
tobj->tm_got = 1;
tobj->gmt = 1;
return time;
}