aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib
diff options
context:
space:
mode:
Diffstat (limited to 'activesupport/lib')
-rw-r--r--activesupport/lib/active_support/json.rb2
-rw-r--r--activesupport/lib/active_support/json/encoders/date.rb6
-rw-r--r--activesupport/lib/active_support/json/encoders/date_time.rb6
-rw-r--r--activesupport/lib/active_support/json/encoders/time.rb6
4 files changed, 17 insertions, 3 deletions
diff --git a/activesupport/lib/active_support/json.rb b/activesupport/lib/active_support/json.rb
index 6c828293e8..5acb02dbe9 100644
--- a/activesupport/lib/active_support/json.rb
+++ b/activesupport/lib/active_support/json.rb
@@ -2,6 +2,8 @@ require 'active_support/json/encoding'
require 'active_support/json/decoding'
module ActiveSupport
+ mattr_accessor :use_standard_json_time_format
+
module JSON
RESERVED_WORDS = %w(
abstract delete goto private transient
diff --git a/activesupport/lib/active_support/json/encoders/date.rb b/activesupport/lib/active_support/json/encoders/date.rb
index d55f17962b..cb9419d29d 100644
--- a/activesupport/lib/active_support/json/encoders/date.rb
+++ b/activesupport/lib/active_support/json/encoders/date.rb
@@ -5,6 +5,10 @@ class Date
# Date.new(2005,2,1).to_json
# # => "2005/02/01"
def to_json(options = nil)
- %("#{strftime("%Y/%m/%d")}")
+ if ActiveSupport.use_standard_json_time_format
+ %("#{strftime("%Y-%m-%d")}")
+ else
+ %("#{strftime("%Y/%m/%d")}")
+ end
end
end
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
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