# class String

### Public Instance Methods

to_date() click to toggle source

Parse data from string.

    # File lib/facets/date.rb, line 427
    def to_date
      #::Date::civil(*ParseDate.parsedate(self)[0..2])
      ::Date.new(*::Date._parse(self, false).values_at(:year, :mon, :mday))
    end

to_datetime() click to toggle source

Convert string to DateTime.

    # File lib/facets/date.rb, line 421
    def to_datetime
      date = ::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec).map { |arg| arg || 0 }
      ::DateTime.civil(*date)
    end

to_t( &yld ) click to toggle source

Translates a string in the form on a set of numerical and/or alphanumerical characters separated by non-word characters (eg W+) into a Tuple. The values of the tuple will be converted to integers if they are purely numerical.

    '1.2.3a'.to_t  #=> [1,2,"3a"]

It you would like to control the interpretation of each value as it is added to the tuple you can supply a block.

    '1.2.3a'.to_t { |v| v.upcase }  #=> ["1","2","3A"]

This method calls Tuple#cast_from_string.

    # File lib/facets/tuple.rb, line 266
    def to_t( &yld )
      Tuple.cast_from_string( self, &yld )
    end

to_time(form = :utc) click to toggle source

    # File lib/facets/date.rb, line 416
    def to_time(form = :utc)
      ::Time.__send__("#{form}_time", *::Date._parse(self, false).values_at(:year, :mon, :mday, :hour, :min, :sec).map{|arg| arg || 0 })
    end