From: Mike Fletcher Date: 2006-05-03T04:50:01+09:00 Subject: Re: parsedate doesn't work on Time.now.to_s Julian Gall wrote: > require 'parsedate' > Time.now > => Tue May 02 20:17:57 GMT Standard Time 2006 > ParseDate.parsedate(Time.now.to_s) > => [nil, 5, 2, 20, 17, 57, "GMT", 2] > > It seems that parsedate is not able to detect the year from the standard > string conversion of a date/time. Is there another way to do this? Is it > the same in the US as for me here in the UK? It seems rather > inconsistent. Hrmm. Works for me (ruby 1.8.4) reirb(main):001:0> require 'parsedate' => true irb(main):002:0> Time.now => Tue May 02 15:46:56 EDT 2006 irb(main):003:0> ParseDate.parsedate( Time.now.to_s ) => [2006, 5, 2, 15, 47, 7, "EDT", 2] irb(main):005:0> ENV['TZ']='GMT' => "GMT" irb(main):006:0> Time.now => Tue May 02 19:47:24 GMT 2006 irb(main):007:0> ParseDate.parsedate( Time.now.to_s ) => [2006, 5, 2, 19, 47, 27, "GMT", 2] My guess is the "GMT Standard Time" is throwing it off. irb(main):001:0> s = Time.now.to_s => "Tue May 02 15:48:28 EDT 2006" irb(main):002:0> s.sub!( /EDT/, "GMT Standard Time" ) => "Tue May 02 15:48:28 GMT Standard Time 2006" irb(main):003:0> require 'parsedate' => true irb(main):004:0> ParseDate.parsedate( s ) => [nil, 5, 2, 15, 48, 28, "GMT", 2] -- Posted via http://www.ruby-forum.com/.