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

Ticket #8399: patch_for_date_time_json.diff

File patch_for_date_time_json.diff, 1.4 kB (added by wycats, 1 year 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   
     34  TimeTests     = [[ Time.at(0), "\"12/31/1969 16:00:00 #{ Time.at(0).zone }\"" ]] 
     35 
    3236  constants.grep(/Tests$/).each do |class_tests| 
    3337    define_method("test_#{class_tests[0..-6].downcase}") do 
    3438      self.class.const_get(class_tests).each do |pair| 
  • lib/active_support/json/encoders/date.rb

    old new  
     1class Date 
     2  def to_json #:nodoc: 
     3    "\"#{ strftime("%m/%d/%Y") }\"" 
     4  end 
     5end 
  • lib/active_support/json/encoders/time.rb

    old new  
     1class Time 
     2  def to_json #:nodoc: 
     3    "\"#{ strftime("%m/%d/%Y %H:%M:%S %Z") }\"" 
     4  end 
     5end