Sha256: d356b1322d0d640cba47aea7ee5584eaea0418dce8fe5b44d925d4407344d0c0

Contents?: true

Size: 748 Bytes

Versions: 19

Compression:

Stored size: 748 Bytes

Contents

require 'parsedate'

module ActiveSupport #:nodoc:
  module CoreExtensions #:nodoc:
    module String #:nodoc:
      # Converting strings to other objects
      module Conversions
        # 'a'.ord == 'a'[0] for Ruby 1.9 forward compatibility.
        def ord
          self[0]
        end if RUBY_VERSION < '1.9'

        # Form can be either :utc (default) or :local.
        def to_time(form = :utc)
          ::Time.send("#{form}_time", *ParseDate.parsedate(self)[0..5].map {|arg| arg || 0})
        end

        def to_date
          ::Date.new(*ParseDate.parsedate(self)[0..2])
        end

        def to_datetime
          ::DateTime.civil(*ParseDate.parsedate(self)[0..5].map {|arg| arg || 0} << 0)
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 4 rubygems

Version Path
activesupport-2.0.4 lib/active_support/core_ext/string/conversions.rb
activesupport-2.0.5 lib/active_support/core_ext/string/conversions.rb
activesupport-2.0.2 lib/active_support/core_ext/string/conversions.rb
radiant-0.6.5.1 vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb
radiant-0.6.5 vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb
radiant-0.6.6 vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb
radiant-0.6.7 vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb
radiant-0.6.9 vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb
radiant-0.6.8 vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb
spree-0.0.9 vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb
spree-0.2.0 vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb
swivel-0.0.150 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/conversions.rb
swivel-0.0.149 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/conversions.rb
swivel-0.0.155 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/conversions.rb
swivel-0.0.152 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/conversions.rb
swivel-0.0.157 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/conversions.rb
swivel-0.0.160 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/conversions.rb
swivel-0.0.175 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/conversions.rb
swivel-0.0.156 vendor/activesupport-2.0.2-/lib/active_support/core_ext/string/conversions.rb