summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--strftime.c2
-rw-r--r--test/ruby/test_time.rb5
2 files changed, 6 insertions, 1 deletions
diff --git a/strftime.c b/strftime.c
index f4180fdb9e..88cdb2198c 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) {
+ if (off < 0 || (off == 0 && (flags & BIT_OF(LEFT)))) {
off = -off;
sign = -1;
}
diff --git a/test/ruby/test_time.rb b/test/ruby/test_time.rb
index b264e7f73c..4e8689bbda 100644
--- a/test/ruby/test_time.rb
+++ b/test/ruby/test_time.rb
@@ -920,6 +920,11 @@ class TestTime < Test::Unit::TestCase
assert_equal("+09:00", t.strftime("%:z"))
assert_equal("+09:00:01", t.strftime("%::z"))
assert_equal("+09:00:01", t.strftime("%:::z"))
+
+ assert_equal("+0000", t2000.strftime("%z"))
+ assert_equal("-0000", t2000.strftime("%-z"))
+ assert_equal("-00:00", t2000.strftime("%-:z"))
+ assert_equal("-00:00:00", t2000.strftime("%-::z"))
end
def test_strftime_padding