aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/json/encoders/time.rb
diff options
context:
space:
mode:
authorRick Olson <technoweenie@gmail.com>2008-04-01 20:25:26 +0000
committerRick Olson <technoweenie@gmail.com>2008-04-01 20:25:26 +0000
commit1eb57a6870cbaa0f965f1c1cf7681a67785e71b0 (patch)
tree329bceef9208beeae74d7f043f1a3fcb8aafb3aa /activesupport/lib/active_support/json/encoders/time.rb
parentd450ac4459165e3af6e45798a6afeac1876f3bc4 (diff)
downloadrails-1eb57a6870cbaa0f965f1c1cf7681a67785e71b0.tar.gz
rails-1eb57a6870cbaa0f965f1c1cf7681a67785e71b0.tar.bz2
rails-1eb57a6870cbaa0f965f1c1cf7681a67785e71b0.zip
Add config.active_support.use_standard_json_time_format setting so that Times and Dates export to ISO 8601 dates. [rick]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9203 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activesupport/lib/active_support/json/encoders/time.rb')
-rw-r--r--activesupport/lib/active_support/json/encoders/time.rb6
1 files changed, 5 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/json/encoders/time.rb b/activesupport/lib/active_support/json/encoders/time.rb
index b0c9189c78..3660d87c82 100644
--- a/activesupport/lib/active_support/json/encoders/time.rb
+++ b/activesupport/lib/active_support/json/encoders/time.rb
@@ -5,6 +5,10 @@ class Time
# Time.utc(2005,2,1,15,15,10).to_json
# # => 2005/02/01 15:15:10 +0000"
def to_json(options = nil)
- %("#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}")
+ if ActiveSupport.use_standard_json_time_format
+ utc.xmlschema.inspect
+ else
+ %("#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}")
+ end
end
end