Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source
Show
Ignore:
Timestamp:
04/01/08 20:25:26 (5 months ago)
Author:
rick
Message:

Add config.active_support.use_standard_json_time_format setting so that Times and Dates export to ISO 8601 dates. [rick]

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/lib/active_support/json/encoders/date_time.rb

    r9093 r9203  
    66  #   # => "2005/02/01 15:15:10 +0000" 
    77  def to_json(options = nil) 
    8     %("#{strftime("%Y/%m/%d %H:%M:%S %z")}") 
     8    if ActiveSupport.use_standard_json_time_format 
     9      xmlschema.inspect 
     10    else 
     11      %("#{strftime("%Y/%m/%d %H:%M:%S %z")}") 
     12    end 
    913  end 
    1014end 
  • trunk/activesupport/lib/active_support/json/encoders/date.rb

    r9093 r9203  
    66  #   # => "2005/02/01" 
    77  def to_json(options = nil) 
    8     %("#{strftime("%Y/%m/%d")}") 
     8    if ActiveSupport.use_standard_json_time_format 
     9      %("#{strftime("%Y-%m-%d")}") 
     10    else 
     11      %("#{strftime("%Y/%m/%d")}") 
     12    end 
    913  end 
    1014end 
  • trunk/activesupport/lib/active_support/json/encoders/time.rb

    r9093 r9203  
    66  #   # => 2005/02/01 15:15:10 +0000" 
    77  def to_json(options = nil) 
    8     %("#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}") 
     8    if ActiveSupport.use_standard_json_time_format 
     9      utc.xmlschema.inspect 
     10    else 
     11      %("#{strftime("%Y/%m/%d %H:%M:%S")} #{formatted_offset(false)}") 
     12    end 
    913  end 
    1014end