Ticket #9750: unambiguous_time_date_and_datetime_to_json.diff
| File unambiguous_time_date_and_datetime_to_json.diff, 2.1 kB (added by gbuesing, 2 years ago) |
|---|
-
test/json/encoding_test.rb
old new 29 29 [ ActiveSupport::JSON::Variable.new('alert("foo")'), 'alert("foo")']] 30 30 RegexpTests = [[ /^a/, '/^a/' ], [/^\w{1,2}[a-z]+/ix, '/^\\w{1,2}[a-z]+/ix']] 31 31 32 DateTests = [[ Date.new(2005, 1,1), %("01/01/2005") ]]33 TimeTests = [[ Time. at(0), %("#{Time.at(0).strftime('%m/%d/%Y %H:%M:%S %Z')}") ]]34 DateTimeTests = [[ DateTime. new(0), %("#{DateTime.new(0).strftime('%m/%d/%Y %H:%M:%S %Z')}") ]]32 DateTests = [[ Date.new(2005,2,1), %("2005/02/01") ]] 33 TimeTests = [[ Time.utc(2005,2,1,15,15,10), %("2005/02/01 15:15:10 UTC") ]] 34 DateTimeTests = [[ DateTime.civil(2005,2,1,15,15,10), %("2005/02/01 15:15:10 +00:00") ]] 35 35 36 36 constants.grep(/Tests$/).each do |class_tests| 37 37 define_method("test_#{class_tests[0..-6].downcase}") do -
lib/active_support/json/encoders/date.rb
old new 1 1 class Date 2 2 def to_json #:nodoc: 3 %("#{strftime("% m/%d/%Y")}")3 %("#{strftime("%Y/%m/%d")}") 4 4 end 5 5 end -
lib/active_support/json/encoders/time.rb
old new 1 1 class Time 2 2 def to_json #:nodoc: 3 %("#{strftime("% m/%d/%Y%H:%M:%S %Z")}")3 %("#{strftime("%Y/%m/%d %H:%M:%S %Z")}") 4 4 end 5 5 end -
lib/active_support/json/encoders/date_time.rb
old new 1 1 class DateTime 2 2 def to_json #:nodoc: 3 %("#{strftime("% m/%d/%Y%H:%M:%S %Z")}")3 %("#{strftime("%Y/%m/%d %H:%M:%S %Z")}") 4 4 end 5 5 end