Changeset 8403
- Timestamp:
- 12/15/07 02:28:32 (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/lib/active_support/core_ext/string/conversions.rb
r8199 r8403 6 6 # Converting strings to other objects 7 7 module Conversions 8 # 'a'.ord == 'a'[0] for Ruby 1.9 forward compatibility. 9 def ord 10 self[0] 11 end if RUBY_VERSION < '1.9' 12 8 13 # Form can be either :utc (default) or :local. 9 14 def to_time(form = :utc) … … 14 19 ::Date.new(*ParseDate.parsedate(self)[0..2]) 15 20 end 16 21 17 22 def to_datetime 18 23 ::DateTime.civil(*ParseDate.parsedate(self)[0..5].map {|arg| arg || 0} << 0) trunk/activesupport/test/core_ext/string_ext_test.rb
r8397 r8403 77 77 assert_equal(human, underscore.humanize) 78 78 end 79 end 80 81 def test_ord 82 assert_equal 97, 'a'.ord 83 assert_equal 97, 'abc'.ord 79 84 end 80 85