A TEXT POST

String conversions using ActiveSupport

ActiveSupport adds some methods to convert strings into dates/times, it’s very nice, take a look.

Instead:

>> Date.parse('2010-01-12')
=> Tue, 12 Jan 2010

You can do:

>> '2010-01-12'.to_date
=> Tue, 12 Jan 2010

It’s very more intuitive and readable!

http://api.rubyonrails.org/classes/ActiveSupport/CoreExtensions/String/Conversions.html

  1. rubyloveinfo reblogged this from rubyquicktips
  2. unsuns reblogged this from rubyquicktips
  3. atm09td reblogged this from rubyquicktips
  4. rubyquicktips reblogged this from rafaelss and added:
    dates/times. It’s...Check out the api docs.
  5. rafaelss posted this