From: "Jesús Gabriel y Galán" Date: 2011-01-27T01:02:18+09:00 Subject: Re: Issues with Time.parse On Wed, Jan 26, 2011 at 4:56 PM, Jens Finnäs wrote: > Hi, > > I just started working my way around web scraping with Ruby and I  just > run in to some problems with Time.parse. > > I'm scraping a date from a website: > > collect_last_bid = > last_bid_cell.scan(/\d{1,2}\.\d{1,2}\.\d{1,4}\b.\b\d{1,2}\:\d{1,2}:\d{1,2}/) > > ...which comes out nicely as "26.01.2011 21:00:08" > > However, when I Time.parse the variable: > > right_now = Time.parse(collect_last_bid) > > ...I get "Error in time.rb, Line 240 in 'parse'" > > Parsing the string with Time.parse("26.01.2011 21:00:08") works fine. > > Any thoughts? String#scan returns an array: irb(main):001:0> s = "26.01.2011 21:00:08" => "26.01.2011 21:00:08" irb(main):003:0> time = s.scan(/\d{1,2}\.\d{1,2}\.\d{1,4}\b.\b\d{1,2}\:\d{1,2}:\d{1,2}/) => ["26.01.2011 21:00:08"] irb(main):005:0> require 'time' => true irb(main):006:0> Time.parse(time) NoMethodError: private method `gsub!' called for ["26.01.2011 21:00:08"]:Array from /usr/lib/ruby/1.8/date/format.rb:1061:in `_parse' from /usr/lib/ruby/1.8/time.rb:240:in `parse' from (irb):6 from :0 irb(main):007:0> Time.parse(time[0]) => Wed Jan 26 21:00:08 +0100 2011 Jesus.