Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions ext/date/date_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -486,14 +486,14 @@ date_zone_to_diff(VALUE str)
#define out_of_range(v, min, max) ((v) < (min) || (max) < (v))
hour = STRTOUL(s, &p, 10);
if (*p == ':') {
if (out_of_range(sec, 0, 59)) return Qnil;
if (out_of_range(hour, 0, 23)) return Qnil;
s = ++p;
min = STRTOUL(s, &p, 10);
if (out_of_range(min, 0, 59)) return Qnil;
if (*p == ':') {
s = ++p;
sec = STRTOUL(s, &p, 10);
if (out_of_range(hour, 0, 23)) return Qnil;
if (out_of_range(sec, 0, 59)) return Qnil;
}
}
else if (*p == ',' || *p == '.') {
Expand Down
5 changes: 5 additions & 0 deletions test/date/test_date_strptime.rb
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,11 @@ def test__strptime__fail
assert_not_nil(Date._strptime('Januari', '%B'))
assert_nil(Date._strptime('Sundai,', '%A,'))
assert_nil(Date._strptime('Januari,', '%B,'))

assert_nil(Date._strptime('+24:00', '%Z')[:offset])
assert_nil(Date._strptime('+23:60', '%Z')[:offset])
assert_nil(Date._strptime('+23:00:60', '%Z')[:offset])
assert_nil(Date._strptime('+23:00:60', '%Z')[:offset])
end

def test_strptime
Expand Down