[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Getting a precise timestamp

angusma

7/31/2006 4:00:00 PM

I am new to Ruby and am trying to get the precise time (down to a fraction
of a second). For example, I did this:

require 'date'
now = DateTime.now
puts sprintf ("The current time is: %2d:%2d:%5.2f", now.hour, now.min,
now.sec+now.sec_fraction)

However, I discover that now.sec_fraction is always zero. Am I not using the
right object?

Thanks in advance for any help.

A Ma


2 Answers

Yohanes Santoso

7/31/2006 4:42:00 PM

0

<angusma@attglobal.net> writes:

> I am new to Ruby and am trying to get the precise time (down to a fraction
> of a second). For example, I did this:

Time.new
Time.new.usec


YS.

angusma

7/31/2006 6:17:00 PM

0


"Yohanes Santoso" <ysantoso-rubytalk@dessyku.is-a-geek.org> wrote in message
news:87odv5hglj.fsf@dessyku.is-a-geek.org...
> <angusma@attglobal.net> writes:
>
>> I am new to Ruby and am trying to get the precise time (down to a
>> fraction
>> of a second). For example, I did this:
>
> Time.new
> Time.new.usec
>
>
> YS.
>

It works. Thanks a lot for your help.

A Ma