提交 18d63693 编写于 作者: L Levin Alexander 提交者: Geoff Buesing

Make TimeWithZone#to_formatted_s an alias to TimeWithZone#to_s [#1796 state:resolved]

上级 5fbacde2
*Edge*
* Make TimeWithZone#to_formatted_s an alias to TimeWithZone#to_s #1796 [Levin Alexander]
* Introduce Array.wrap(foo) to wrap the argument in an array unless it's already an array. Wraps nil as an empty array. Use instead of Array(foo) and foo.to_a since they treat String as Enumerable. [Jeremy Kemper]
......
......@@ -155,6 +155,7 @@ def to_s(format = :default)
"#{time.strftime("%Y-%m-%d %H:%M:%S")} #{formatted_offset(false, 'UTC')}" # mimicking Ruby 1.9 Time#to_s format
end
end
alias_method :to_formatted_s, :to_s
# Replaces <tt>%Z</tt> and <tt>%z</tt> directives with +zone+ and +formatted_offset+, respectively, before passing to
# Time#strftime, so that zone information is correct
......
......@@ -93,6 +93,12 @@ def test_to_s
end
end
def test_to_formatted_s
silence_warnings do # silence warnings raised by tzinfo gem
assert_equal '1999-12-31 19:00:00 -0500', @twz.to_formatted_s
end
end
def test_to_s_db
silence_warnings do # silence warnings raised by tzinfo gem
assert_equal '2000-01-01 00:00:00', @twz.to_s(:db)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册