On Fri, 9 Sep 2005, 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)
>
> 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.
>
> Is there a cunning way to do this I have missed?  Do I need another
> library and if so, what?
>
>        Thank you,
>        Hugh

this might help...

   harp:~ > cat a.rb
   require 'alib'

   now = Time::now
   p now

   now_s = ALib::Util::timestamp now
   p now_s

   p ALib::Util::stamptime(now_s, 'local' => true)
   harp:~ > ruby a.rb


   Thu Sep 08 12:31:26 MDT 2005
   "2005-09-08 18:31:26.812671"
   Thu Sep 08 18:31:26 MDT 2005

dunno though... without the 'local' it assumes utc.

cheers.

-a
-- 
===============================================================================
| email :: ara [dot] t [dot] howard [at] noaa [dot] gov
| phone :: 303.497.6469
| Your life dwells amoung the causes of death
| Like a lamp standing in a strong breeze.  --Nagarjuna
===============================================================================