未验证 提交 4d635bd6 编写于 作者: J Jeremy Daer

Merge pull request #24552 from yui-knk/raise_argument_error

Raise `ArgumentError` when an invalid form is passed to `Date#to_time`
......@@ -80,6 +80,7 @@ def readable_inspect
#
# date.to_time(:utc) # => 2007-11-10 00:00:00 UTC
def to_time(form = :local)
raise ArgumentError, "Expected :local or :utc, got #{form.inspect}." unless [:local, :utc].include?(form)
::Time.send(form, year, month, day)
end
......
......@@ -49,6 +49,10 @@ def test_to_time
end
end
end
assert_raise(ArgumentError) do
Date.new(2005, 2, 21).to_time(:tokyo)
end
end
def test_compare_to_time
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册