Time Conversion 
Author Message
 Time Conversion

How do I convert an integer to a time and date?  Specifically, given:

t = File.mtime(x).to_i

I want to be able to:

printf("%s\n", t.to_time)

How do you define the method to_time?  Doesn't seem to be any built-ins, even though I find that odd.  Nothing in class Integer, Float, or Fixnum - and nothing in ParseDate about "seconds since epoch" or integers and such.

David Douthitt
CUNA & Affiliates
UNIX Systems Administrator

(608) 231-4922



Sat, 08 Jan 2005 05:52:52 GMT  
 Time Conversion

Quote:

> How do I convert an integer to a time and date?  Specifically, given:

> t = File.mtime(x).to_i

> I want to be able to:

> printf("%s\n", t.to_time)

Look at Time.at().  In your case, I think this should work ...

   printf "%s\n", Time.at(t)



Sat, 08 Jan 2005 06:08:21 GMT  
 Time Conversion
Hi --

Quote:


> > How do I convert an integer to a time and date?  Specifically, given:

> > t = File.mtime(x).to_i

> > I want to be able to:

> > printf("%s\n", t.to_time)

> Look at Time.at().  In your case, I think this should work ...

>    printf "%s\n", Time.at(t)

Digressing slightly from the question, but I'd put in a plug for:

  puts Time.at(t)

:-)

David

--
David Alan Black


Web:  http://pirate.shu.edu/~blackdav



Sat, 08 Jan 2005 06:15:54 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. UTC time conversion to internal time

2. Time conversion

3. Time conversion

4. Time conversion

5. Time Conversions

6. Date & Time Conversions on VM

7. date/time conversion

8. string to date/time conversion

9. FILETIME <-> Ada.Real_Time.Time conversions

10. Integer - Time Conversion that actually works!

11. Time conversion

12. Date/Time conversions

 

 
Powered by phpBB® Forum Software