Sha256: 2473e9b8e54fc3f106cd277454f5b64815de82c6f25372154793bf3366ba2ecd
Contents?: true
Size: 620 Bytes
Versions: 2
Compression:
Stored size: 620 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}_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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
activesupport-2.0.0 | lib/active_support/core_ext/string/conversions.rb |
activesupport-2.0.1 | lib/active_support/core_ext/string/conversions.rb |