|
|
||
"2007年1月27日午後3時10分32秒"のような「年・月・日・時・分・秒」を使った時刻をTimeオブジェクトに変換して返すメソッドを定義
require "time" def jparsedate(str) # "2007年1月27日午後3時10分32秒" -> "20070127031032" fstr = str.scan(/\d+/).map{|s| s.size == 1 ? "0".concat(s) : s}.join t = Time.parse(fstr) m = /午後/.match(str) t += 60 * 60 * 12 unless m.nil? # 午後だったら12時間進める return t end p jparsedate("2007年1月27日午後3時10分32秒")