Sha256: e99325cc34000ca6796588aad817cab4af97341970bb99918fa9876d0a86490e

Contents?: true

Size: 451 Bytes

Versions: 82

Compression:

Stored size: 451 Bytes

Contents

require 'parsedate'

module ActiveSupport #:nodoc:
  module CoreExtensions #:nodoc:
    module String #:nodoc:
      # Converting strings to other objects
      module Conversions
        # Form can be either :utc (default) or :local.
        def to_time(form = :utc)
          ::Time.send(form, *ParseDate.parsedate(self))
        end

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

Version data entries

82 entries across 82 versions & 5 rubygems

Version Path
activesupport-1.0.2 lib/active_support/core_ext/string/conversions.rb
activesupport-1.0.4 lib/active_support/core_ext/string/conversions.rb
activesupport-1.0.3 lib/active_support/core_ext/string/conversions.rb
activesupport-1.0.1 lib/active_support/core_ext/string/conversions.rb
activesupport-1.4.2 lib/active_support/core_ext/string/conversions.rb
activesupport-1.3.0 lib/active_support/core_ext/string/conversions.rb
activesupport-1.4.3 lib/active_support/core_ext/string/conversions.rb
activesupport-1.3.1 lib/active_support/core_ext/string/conversions.rb
activesupport-1.4.1 lib/active_support/core_ext/string/conversions.rb
activesupport-1.1.0 lib/active_support/core_ext/string/conversions.rb
activesupport-1.2.1 lib/active_support/core_ext/string/conversions.rb
activesupport-1.2.5 lib/active_support/core_ext/string/conversions.rb
activesupport-1.2.4 lib/active_support/core_ext/string/conversions.rb
activesupport-1.4.0 lib/active_support/core_ext/string/conversions.rb
activesupport-1.4.4 lib/active_support/core_ext/string/conversions.rb
activesupport-1.2.2 lib/active_support/core_ext/string/conversions.rb
activesupport-1.2.3 lib/active_support/core_ext/string/conversions.rb
activesupport-1.1.1 lib/active_support/core_ext/string/conversions.rb
backlog-0.0.0 vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb
backlog-0.0.1 vendor/rails/activesupport/lib/active_support/core_ext/string/conversions.rb