提交 e1790efb 编写于 作者: R Rick Olson

Ensure that TimeWithZone#to_yaml works when passed a YAML::Emitter. [rick]

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9081 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
上级 03813987
*SVN*
* Ensure that TimeWithZone#to_yaml works when passed a YAML::Emitter. [rick]
* Ensure correct TimeWithZone#to_date [Geoff Buesing]
* Make TimeWithZone work with tzinfo 0.2.x: use TZInfo::Timezone#zone_identifier alias for #abbreviation, silence warnings on tests. Raise LoadError when TZInfo version is < 0.2 by sniffing for TZInfo::TimeOrDateTime constant. Move all tzinfo-dependent TimeZone tests into uses_tzinfo block [Geoff Buesing]
......
......@@ -80,7 +80,11 @@ def to_json(options = nil)
end
def to_yaml(options = {})
time.to_yaml(options).gsub('Z', formatted_offset(true, 'Z'))
if options.kind_of?(YAML::Emitter)
utc.to_yaml(options)
else
time.to_yaml(options).gsub('Z', formatted_offset(true, 'Z'))
end
end
def httpdate
......
......@@ -106,6 +106,12 @@ def test_to_yaml
end
end
def test_ruby_to_yaml
silence_warnings do
assert_equal "--- \n:twz: 2000-01-01 00:00:00 Z\n", {:twz => @twz}.to_yaml
end
end
def test_httpdate
silence_warnings do # silence warnings raised by tzinfo gem
assert_equal 'Sat, 01 Jan 2000 00:00:00 GMT', @twz.httpdate
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册