From: Eric Hodel Date: 2005-09-09T09:30:14+09:00 Subject: Re: File.mtime <=> DateTime.strptime() On 08 Sep 2005, at 11:11, Hugh Sasse wrote: > I'm trying to compare how new a file is with the header obtained > from Net::HTTP.head(). I use > > STRFTIME_FORMAT = "%a, %d %b %Y %H:%M:%S GMT" > timestamp = DateTime.strptime(lastmod, STRFTIME_FORMAT) require 'time' timestamp = Time.parse lastmod > But I can't compare this with the results of File.mtime, because one > is a DateTime, and one is a Time. Time::strptime or Time::strftime > don't exist. Time#strftime does, but I can't pass a string to be > turned into a time into it. Parsedate deosn't seem to handle this > case, either in so far as it has no str[fp]time. Time.parse Just Works. > Is there a cunning way to do this I have missed? Do I need another > library and if so, what? I tend to avoid Date and DateTime unless I need them. -- Eric Hodel - drbrain@segment7.net - http://segment7.net FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04