[Bug #20797] Check seconds in UTC offset as well as minutes
This commit is contained in:
parent
0641951e7b
commit
9611c619ac
Notes:
git
2024-10-14 05:24:55 +00:00
@ -625,15 +625,15 @@ describe "Time.new with a timezone argument" do
|
|||||||
|
|
||||||
-> {
|
-> {
|
||||||
Time.new("2020-12-25 00:56:17 +23:59:60")
|
Time.new("2020-12-25 00:56:17 +23:59:60")
|
||||||
}.should raise_error(ArgumentError, "utc_offset out of range")
|
}.should raise_error(ArgumentError, /utc_offset/)
|
||||||
|
|
||||||
-> {
|
-> {
|
||||||
Time.new("2020-12-25 00:56:17 +24:00")
|
Time.new("2020-12-25 00:56:17 +24:00")
|
||||||
}.should raise_error(ArgumentError, "utc_offset out of range")
|
}.should raise_error(ArgumentError, /utc_offset/)
|
||||||
|
|
||||||
-> {
|
-> {
|
||||||
Time.new("2020-12-25 00:56:17 +23:61")
|
Time.new("2020-12-25 00:56:17 +23:61")
|
||||||
}.should raise_error(ArgumentError, '"+HH:MM", "-HH:MM", "UTC" or "A".."I","K".."Z" expected for utc_offset: +23:61')
|
}.should raise_error(ArgumentError, /utc_offset/)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "raises ArgumentError if string has not ascii-compatible encoding" do
|
it "raises ArgumentError if string has not ascii-compatible encoding" do
|
||||||
|
@ -152,6 +152,18 @@ class TestTime < Test::Unit::TestCase
|
|||||||
assert_raise_with_message(ArgumentError, /can't parse/) {
|
assert_raise_with_message(ArgumentError, /can't parse/) {
|
||||||
Time.new("2020-12-02 00:00:00 ")
|
Time.new("2020-12-02 00:00:00 ")
|
||||||
}
|
}
|
||||||
|
assert_raise_with_message(ArgumentError, /utc_offset/) {
|
||||||
|
Time.new("2020-12-25 00:00:00 +0960")
|
||||||
|
}
|
||||||
|
assert_raise_with_message(ArgumentError, /utc_offset/) {
|
||||||
|
Time.new("2020-12-25 00:00:00 +09:60")
|
||||||
|
}
|
||||||
|
assert_raise_with_message(ArgumentError, /utc_offset/) {
|
||||||
|
Time.new("2020-12-25 00:00:00 +090060")
|
||||||
|
}
|
||||||
|
assert_raise_with_message(ArgumentError, /utc_offset/) {
|
||||||
|
Time.new("2020-12-25 00:00:00 +09:00:60")
|
||||||
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_time_add()
|
def test_time_add()
|
||||||
|
1
time.c
1
time.c
@ -2211,6 +2211,7 @@ utc_offset_arg(VALUE arg)
|
|||||||
}
|
}
|
||||||
if (sec) {
|
if (sec) {
|
||||||
if (!have_2digits(sec)) goto invalid_utc_offset;
|
if (!have_2digits(sec)) goto invalid_utc_offset;
|
||||||
|
if (sec[0] > '5') goto invalid_utc_offset;
|
||||||
n += num_from_2digits(sec);
|
n += num_from_2digits(sec);
|
||||||
ASSUME(min);
|
ASSUME(min);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user