Changeset 7746
- Timestamp:
- 10/05/07 09:43:24 (9 months ago)
- Files:
-
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/json/encoders/date_time.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/json/encoders/date.rb (modified) (1 diff)
- trunk/activesupport/lib/active_support/json/encoders/time.rb (modified) (1 diff)
- trunk/activesupport/test/json/encoding_test.rb (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/CHANGELOG
r7739 r7746 1 1 *SVN* 2 3 * Disambiguate Time, Date, and DateTime#to_json formatting. #9750 [Geoff Buesing, Chu Yeow] 2 4 3 5 * Hash#to_json takes :only or :except options to specific or omit certain hash keys. Enumerable#to_json passes through its options to each element. #9751 [Chu Yeow] trunk/activesupport/lib/active_support/json/encoders/date_time.rb
r7736 r7746 1 1 class DateTime 2 2 def to_json(options = nil) #: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 trunk/activesupport/lib/active_support/json/encoders/date.rb
r7736 r7746 1 1 class Date 2 2 def to_json(options = nil) #:nodoc: 3 %("#{strftime("% m/%d/%Y")}")3 %("#{strftime("%Y/%m/%d")}") 4 4 end 5 5 end trunk/activesupport/lib/active_support/json/encoders/time.rb
r7736 r7746 1 1 class Time 2 2 def to_json(options = nil) #:nodoc: 3 %("#{strftime("%m/%d/%Y %H:%M:%S %Z")}")3 to_datetime.to_json(options) 4 4 end 5 5 end trunk/activesupport/test/json/encoding_test.rb
r7736 r7746 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 +0000") ]] 34 DateTimeTests = [[ DateTime.civil(2005,2,1,15,15,10), %("2005/02/01 15:15:10 +0000") ]] 35 35 36 36 constants.grep(/Tests$/).each do |class_tests|