提交 52c9ad4c 编写于 作者: J Jeremy Kemper

DateTime#to_time gives hour/minute/second resolution. Closes #5747.

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4718 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 c3cdd3b6
*SVN*
* DateTime#to_time gives hour/minute/second resolution. #5747 [jon.evans@pobox.com]
* attr_internal to support namespacing and deprecation. Like attr_* except backed by internally-named instance variable. Set attr_internal_naming_format to change the format from the default '@_%s'. [Jeremy Kemper]
# def foo() @foo__rofl end
# def foo=(v) @foo__rofl = v end
......
......@@ -23,8 +23,12 @@ def to_date
end
def to_time(form = :local)
if respond_to?(:hour)
::Time.send(form, year, month, day, hour, min, sec)
else
::Time.send(form, year, month, day)
end
end
def xmlschema
to_time.xmlschema
......
......@@ -10,6 +10,10 @@ def test_to_time
assert_equal Time.local(2005, 2, 21), Date.new(2005, 2, 21).to_time
end
def test_to_time_on_datetime
assert_equal Time.local(2005, 2, 21, 10, 11, 12), DateTime.new(2005, 2, 21, 10, 11, 12).to_time
end
def test_to_date
assert_equal Date.new(2005, 2, 21), Date.new(2005, 2, 21).to_date
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册