mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Add Time#to_s(:iso8601) for easy conversion of times to the iso8601 format for easy Javascript date parsing
This commit is contained in:
parent
586173204c
commit
b67a80de9b
3 changed files with 7 additions and 1 deletions
|
@ -1,3 +1,7 @@
|
|||
* 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 @@ class TimeExtCalculationsTest < ActiveSupport::TestCase
|
|||
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
|
||||
|
|
Loading…
Reference in a new issue