Show seconds of utc_offset if not zero
This commit is contained in:
parent
f7dc4d5cda
commit
b017848f8a
@ -584,6 +584,10 @@ class TestTime < Test::Unit::TestCase
|
|||||||
|
|
||||||
t2000 = get_t2000.localtime(9*3600) + 1/10r
|
t2000 = get_t2000.localtime(9*3600) + 1/10r
|
||||||
assert_equal("2000-01-01 09:00:00.1 +0900", t2000.inspect)
|
assert_equal("2000-01-01 09:00:00.1 +0900", t2000.inspect)
|
||||||
|
|
||||||
|
t2000 = get_t2000
|
||||||
|
assert_equal("2000-01-01 09:12:00 +0912", t2000.localtime(9*3600+12*60).inspect)
|
||||||
|
assert_equal("2000-01-01 09:12:34 +091234", t2000.localtime(9*3600+12*60+34).inspect)
|
||||||
end
|
end
|
||||||
|
|
||||||
def assert_zone_encoding(time)
|
def assert_zone_encoding(time)
|
||||||
|
9
time.c
9
time.c
@ -4099,7 +4099,14 @@ time_inspect(VALUE time)
|
|||||||
rb_str_cat_cstr(str, " UTC");
|
rb_str_cat_cstr(str, " UTC");
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
rb_str_concat(str, strftimev(" %z", time, rb_usascii_encoding()));
|
/* ?TODO: subsecond offset */
|
||||||
|
long off = NUM2LONG(rb_funcall(tobj->vtm.utc_offset, rb_intern("round"), 0));
|
||||||
|
char sign = (off < 0) ? (off = -off, '-') : '+';
|
||||||
|
int sec = off % 60;
|
||||||
|
int min = (off /= 60) % 60;
|
||||||
|
off /= 60;
|
||||||
|
rb_str_catf(str, " %c%.2d%.2d", sign, (int)off, min);
|
||||||
|
if (sec) rb_str_catf(str, "%.2d", sec);
|
||||||
}
|
}
|
||||||
return str;
|
return str;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user