summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_time_tz.rb2
-rw-r--r--time.c4
2 files changed, 5 insertions, 1 deletions
diff --git a/test/ruby/test_time_tz.rb b/test/ruby/test_time_tz.rb
index 37838908b9..fdc9e114b5 100644
--- a/test/ruby/test_time_tz.rb
+++ b/test/ruby/test_time_tz.rb
@@ -261,6 +261,8 @@ class TestTimeTZ < Test::Unit::TestCase
assert_predicate(Time.new(2019, 1, 1, 0, 0, 0, "UTC"), :utc?)
assert_predicate(Time.new(2019, 1, 1, 0, 0, 0, "utc"), :utc?)
assert_predicate(Time.new(2019, 1, 1, 0, 0, 0, "Z"), :utc?)
+ assert_predicate(Time.new(2019, 1, 1, 0, 0, 0, "-00:00"), :utc?)
+ assert_not_predicate(Time.new(2019, 1, 1, 0, 0, 0, "+00:00"), :utc?)
end
def test_military_names
diff --git a/time.c b/time.c
index 050a52615f..bd79110c5e 100644
--- a/time.c
+++ b/time.c
@@ -2150,8 +2150,10 @@ utc_offset_arg(VALUE arg)
if (s[0] != '+' && s[0] != '-') goto invalid_utc_offset;
if (!ISDIGIT(s[1]) || !ISDIGIT(s[2])) goto invalid_utc_offset;
n += (s[1] * 10 + s[2] - '0' * 11) * 3600;
- if (s[0] == '-')
+ if (s[0] == '-') {
+ if (n == 0) return UTC_ZONE;
n = -n;
+ }
return INT2FIX(n);
}
else {