to_s()
public
Show source
static VALUE
time_to_s(VALUE time)
{
struct time_object *tobj;
char buf[128];
int len;
GetTimeval(time, tobj);
if (tobj->tm_got == 0) {
time_get_tm(time, tobj->gmt);
}
if (tobj->gmt == 1) {
len = rb_strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S UTC",
&tobj->tm, &tobj->ts, tobj->gmt);
}
else {
len = rb_strftime(buf, sizeof(buf), "%Y-%m-%d %H:%M:%S %z",
&tobj->tm, &tobj->ts, tobj->gmt);
}
return rb_str_new(buf, len);
}