zone()
public
Returns the name of the time zone used for
time. As of Ruby 1.8, returns
“UTC” rather than “GMT” for UTC times.
t = Time.gm(2000, "jan", 1, 20, 15, 1)
t.zone
t = Time.local(2000, "jan", 1, 20, 15, 1)
t.zone
Show source
static VALUE
time_zone(VALUE time)
{
struct time_object *tobj;
char buf[64];
int len;
GetTimeval(time, tobj);
if (tobj->tm_got == 0) {
time_get_tm(time, tobj->gmt);
}
if (tobj->gmt == 1) {
return rb_str_new2("UTC");
}
return rb_str_new2(tobj->tm.tm_zone);
return rb_str_new2(tzname[daylight && tobj->tm.tm_isdst]);
len = rb_strftime(buf, sizeof(buf), "%Z",
&tobj->tm, &tobj->ts, tobj->gmt);
return rb_str_new(buf, len);
}