Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

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, 9 months ago)
  • test/json/encoding_test.rb

    old new  
    2929                   [ ActiveSupport::JSON::Variable.new('alert("foo")'), 'alert("foo")']] 
    3030  RegexpTests   = [[ /^a/, '/^a/' ], [/^\w{1,2}[a-z]+/ix, '/^\\w{1,2}[a-z]+/ix']] 
    3131 
    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") ]] 
    3535 
    3636  constants.grep(/Tests$/).each do |class_tests| 
    3737    define_method("test_#{class_tests[0..-6].downcase}") do 
  • lib/active_support/json/encoders/date.rb

    old new  
    11class Date 
    22  def to_json #:nodoc: 
    3     %("#{strftime("%m/%d/%Y")}") 
     3    %("#{strftime("%Y/%m/%d")}") 
    44  end 
    55end 
  • lib/active_support/json/encoders/time.rb

    old new  
    11class Time 
    22  def to_json #:nodoc: 
    3     %("#{strftime("%m/%d/%Y %H:%M:%S %Z")}") 
     3    %("#{strftime("%Y/%m/%d %H:%M:%S %Z")}") 
    44  end 
    55end 
  • lib/active_support/json/encoders/date_time.rb

    old new  
    11class DateTime 
    22  def to_json #:nodoc: 
    3     %("#{strftime("%m/%d/%Y %H:%M:%S %Z")}") 
     3    %("#{strftime("%Y/%m/%d %H:%M:%S %Z")}") 
    44  end 
    55end