ruby-changes:65275
From: Nobuyoshi <ko1@a...>
Date: Tue, 16 Feb 2021 20:34:40 +0900 (JST)
Subject: [ruby-changes:65275] 5b7439bb7b (master): UTC zone should be still "+00:00" [Feature #17544]
https://git.ruby-lang.org/ruby.git/commit/?id=5b7439bb7b From 5b7439bb7b1088ef5233175893229970cee339fd Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Tue, 16 Feb 2021 19:28:28 +0900 Subject: UTC zone should be still "+00:00" [Feature #17544] --- strftime.c | 2 +- test/ruby/test_time.rb | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/strftime.c b/strftime.c index 88cdb21..c3d6001 100644 --- a/strftime.c +++ b/strftime.c @@ -547,7 +547,7 @@ rb_strftime_with_timespec(VALUE ftime, const char *format, size_t format_len, https://github.com/ruby/ruby/blob/trunk/strftime.c#L547 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 4e8689b..5d2c7b7 100644 --- a/test/ruby/test_time.rb +++ b/test/ruby/test_time.rb @@ -925,6 +925,12 @@ class TestTime < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_time.rb#L925 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 -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/