From 1eb57a6870cbaa0f965f1c1cf7681a67785e71b0 Mon Sep 17 00:00:00 2001 From: Rick Olson Date: Tue, 1 Apr 2008 20:25:26 +0000 Subject: 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 --- activesupport/lib/active_support/json/encoders/date_time.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'activesupport/lib/active_support/json/encoders/date_time.rb') diff --git a/activesupport/lib/active_support/json/encoders/date_time.rb b/activesupport/lib/active_support/json/encoders/date_time.rb index 380361c360..d41c3e9786 100644 --- a/activesupport/lib/active_support/json/encoders/date_time.rb +++ b/activesupport/lib/active_support/json/encoders/date_time.rb @@ -5,6 +5,10 @@ class DateTime # DateTime.civil(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 %z")}") + if ActiveSupport.use_standard_json_time_format + xmlschema.inspect + else + %("#{strftime("%Y/%m/%d %H:%M:%S %z")}") + end end end -- cgit v1.2.3