diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-02-16 19:28:28 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-02-16 20:34:23 +0900 |
commit | 5b7439bb7b1088ef5233175893229970cee339fd (patch) | |
tree | 6f2847cde90d0970dd5f73e7f1d3edc1c6dcc5af | |
parent | 9ef66ce3fcfee06d628b611dbc22026d7cc72d0e (diff) | |
download | ruby-5b7439bb7b1088ef5233175893229970cee339fd.tar.gz |
UTC zone should be still "+00:00" [Feature #17544]
-rw-r--r-- | strftime.c | 2 | ||||
-rw-r--r-- | test/ruby/test_time.rb | 6 |
2 files changed, 7 insertions, 1 deletions
diff --git a/strftime.c b/strftime.c index 88cdb2198c..c3d600114f 100644 --- a/strftime.c +++ b/strftime.c @@ -547,7 +547,7 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len, else { off = NUM2LONG(rb_funcall(vtm->utc_offset, rb_intern("round"), 0)); } - if (off < 0 || (off == 0 && (flags & BIT_OF(LEFT)))) { + if (off < 0 || (gmt && (flags & BIT_OF(LEFT)))) { off = -off; sign = -1; } diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb index 4e8689bbda..5d2c7b71de 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -925,6 +925,12 @@ class TestTime < Test::Unit::TestCase assert_equal("-0000", t2000.strftime("%-z")) assert_equal("-00:00", t2000.strftime("%-:z")) assert_equal("-00:00:00", t2000.strftime("%-::z")) + + t = t2000.getlocal("+00:00") + assert_equal("+0000", t.strftime("%z")) + assert_equal("+0000", t.strftime("%-z")) + assert_equal("+00:00", t.strftime("%-:z")) + assert_equal("+00:00:00", t.strftime("%-::z")) end def test_strftime_padding |