Taras Koval wrote:
> Hi all,
> I have a problem, I cannot convert string to Time.
> I wrote function, but they don't work:
> 
> def string_to_time(string)
>     return string unless string.is_a?(String)
>     time_hash = Date._parse(string)
>     new_time = Time.mktime(time_hash[:year], time_hash[:mon],
> time_hash[:mday])
>     return new_time
> end
> 
> Please help!

Seems to work ok. What is the problem?

Incidentally, this seems to have the same effect (see the docs for 
Time#parse):

def string_to_time(string)
  return string unless string.is_a? String
  Time.parse(string)
end

Dan

-- 
Posted via http://www.ruby-forum.com/.