From: Ryan Leavengood Date: 2005-07-20T03:36:48+09:00 Subject: Re: Parsing to DateTime James Edward Gray II said: > On Jul 19, 2005, at 1:02 PM, G�bor SEBESTY�N wrote: > >> I have to parse input string to DateTime in format "%Y.%m.%d". How >> can I do it? DateTime.parse() didn't recognize. > > You're looking for Date.strptime(). I also just wrote this up for this special case: def parse_date(str) if str =~ /\A(\d{4})\.(\d{1,2})\.(\d{1,2})\Z/ Time.local($1,$2,$3,0,0,0) end end p parse_date("2005.07.19") p parse_date("2005.7.19") p parse_date("2005.7.9") Which you use depends on whether you want a Date or Time. Ryan