概要
String#conversion
詳細
String#conversion について
String#conversion
Date._parseを便利にしたラッパーのようなメソッド。
サンプル
# encoding: utf-8 require 'active_support/core_ext/string/conversions' require 'tbpgr_utils' bulk_puts_eval binding, <<-EOS "2014-03-04".to_date "2014-03-04 23:37:00".to_time "2014-03-04 23:37:00".to_datetime EOS __END__ ・下記はTbpgrUtils gemの機能 bulk_puts_eval https://rubygems.org/gems/tbpgr_utils https://github.com/tbpgr/tbpgr_utils
出力
"2014-03-04".to_date # => #<Date: 2014-03-04 ((2456721j,0s,0n),+0s,2299161j)> "2014-03-04 23:37:00".to_time # => 2014-03-04 23:37:00 +0900 "2014-03-04 23:37:00".to_datetime # => #<DateTime: 2014-03-04T23:37:00+00:00 ((2456721j,85020s,0n),+0s,2299161j)>