Add Time#to_s(:iso8601) for easy conversion of times to the iso8601 format for...

Add Time#to_s(:iso8601) for easy conversion of times to the iso8601 format for easy Javascript date parsing
上级 58617320
* Add Time#to_s(:iso8601) for easy conversion of times to the iso8601 format for easy Javascript date parsing.
*DHH*
* Improve `ActiveSupport::Cache::MemoryStore` cache size calculation.
The memory used by a key/entry pair is calculated via `#cached_size`:
......
......@@ -16,7 +16,8 @@ class Time
:rfc822 => lambda { |time|
offset_format = time.formatted_offset(false)
time.strftime("%a, %d %b %Y %H:%M:%S #{offset_format}")
}
},
:iso8601 => "%Y-%m-%dT%H:%M:%SZ"
}
# Converts to a formatted string. See DATE_FORMATS for builtin formats.
......
......@@ -503,6 +503,7 @@ def test_to_s
assert_equal "20050221174430123456789", time.to_s(:nsec)
assert_equal "February 21, 2005 17:44", time.to_s(:long)
assert_equal "February 21st, 2005 17:44", time.to_s(:long_ordinal)
assert_equal "2009-02-05T14:30:05Z", Time.local(2009, 2, 5, 14, 30, 5).to_s(:iso8601)
with_env_tz "UTC" do
assert_equal "Mon, 21 Feb 2005 17:44:30 +0000", time.to_s(:rfc822)
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册