aboutsummaryrefslogtreecommitdiffstats
path: root/time.c
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-12 17:00:14 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-01-12 17:00:14 +0900
commitb017848f8a9c907be07f51d6ae6304bff9950594 (patch)
tree7bb1bb2448ddaaff9f569b702da485cc261140df /time.c
parentf7dc4d5cda74e101fa66c1170c0b47deea09c0ee (diff)
downloadruby-b017848f8a9c907be07f51d6ae6304bff9950594.tar.gz
Show seconds of utc_offset if not zero
Diffstat (limited to 'time.c')
-rw-r--r--time.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/time.c b/time.c
index f2f5d173cb..a3952743da 100644
--- a/time.c
+++ b/time.c
@@ -4099,7 +4099,14 @@ time_inspect(VALUE time)
rb_str_cat_cstr(str, " UTC");
}
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;
}