提交 17fee001 编写于 作者: J Jeremy Kemper

:db format for Date#to_s

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6060 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 0eacdcf9
*SVN*
* :db format for Date#to_s [Jeremy Kemper]
Date.new(2007, 1, 27).to_s(:db) # => '2007-01-27'
* Added :instance_writer option to #mattr_writer/accessor, #cattr_writer/accessor, and #class_inheritable_writer to skip the creation of the instance writer. [Rick]
* Added Hash#to_query to turn a hash of values into a form-encoded query string [Nicholas Seckar]
......
......@@ -5,7 +5,8 @@ module Date #:nodoc:
module Conversions
DATE_FORMATS = {
:short => "%e %b",
:long => "%B %e, %Y"
:long => "%B %e, %Y",
:db => "%Y-%m-%d"
}
def self.included(klass) #:nodoc:
......
......@@ -4,6 +4,7 @@ class DateExtCalculationsTest < Test::Unit::TestCase
def test_to_s
assert_equal "21 Feb", Date.new(2005, 2, 21).to_s(:short)
assert_equal "February 21, 2005", Date.new(2005, 2, 21).to_s(:long)
assert_equal "2005-02-21", Date.new(2005, 2, 21).to_s(:db)
end
def test_to_time
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册