Is there a simple way to get a Ruby Date object from a unsigned int32 number representing the number of seconds since January 1st 1970?
Regards,
Herman
Is there a simple way to get a Ruby Date object from a unsigned int32 number representing the number of seconds since January 1st 1970?
Regards,
Herman
fre, 2002-06-07 kl. 16:37 skrev herman_graal@europe.com:
Is there a simple way to get a Ruby Date object from a unsigned int32 number representing the number of seconds since January 1st 1970?
Time.at( Time.now.to_i )
…where you substitute Time.now.to_i with your Fixnum
–
Christian Rishoj
In article 1023461051.1432.17.camel@penelope, Christian Rishoj wrote:
fre, 2002-06-07 kl. 16:37 skrev herman_graal@europe.com:
Is there a simple way to get a Ruby Date object from a unsigned int32 number representing the number of seconds since January 1st 1970?
Time.at( Time.now.to_i )
…where you substitute Time.now.to_i with your Fixnum
But if you want a Date object you might end up saying
require ‘date’
…
myNumber = 9987653
date = Date.new(*Time.at(myNumber).to_a[3 … 5].reverse)
date.to_s # => “1970-04-26”
There must be a nicer way to do it…
Hope this helps,
Mike
–
mike@stok.co.uk | The “`Stok’ disclaimers” apply.
http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA
mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60
http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA