![]() ![]() ![]() ![]() |
![]() |
|
![]() |
||
![]() |
"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秒")
Wong
2013/01/16 19:43
Such an impressive answer! You've betean us all with that!
Wong
2013/01/16 19:43
Such an impressive answer! You've betean us all with that!
pwbjdjz
2013/01/17 16:49
LfpDRl <a href="http://livgeeljvewr.com/">livgeeljvewr</a>
bmrjox
2013/01/17 16:49
yEFaC7 <a href="http://spyvrvgvtwms.com/">spyvrvgvtwms</a>
sdohbzzp
2013/01/17 16:49
YdeOLR <a href="http://fhoiwdwnxcav.com/">fhoiwdwnxcav</a>
bmrjox
2013/01/17 16:49
yEFaC7 <a href="http://spyvrvgvtwms.com/">spyvrvgvtwms</a>
cnxuzavbo
2013/01/17 21:19
OwdS1g , [url=http://arrxwhlqjayv.com/]arrxwhlqjayv[/url], [link=http://trjkayeoukoy.com/]trjkayeoukoy[/link], http://uvjtbpfvsooe.com/