1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

Parse "-00:00" as UTC for the round-trip [Feature #17544]

This commit is contained in:
Nobuyoshi Nakada 2021-02-16 19:36:20 +09:00
parent 5b7439bb7b
commit 296a2cab07
Notes: git 2021-02-16 20:34:46 +09:00
2 changed files with 5 additions and 1 deletions

View file

@ -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

4
time.c
View file

@ -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 {