realbasic-nug
[Top] [All Lists]

Re: Tenths of seconds in Date

To: realbasic-nug at lists dot realsoftware dot com
Subject: Re: Tenths of seconds in Date
From: Paul Rodman <paul at ilanga dot com>
Date: Fri, 29 Jun 2007 07:36:58 -0700
Delivered-to: listarchive at realsoftware dot com
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <mailman dot 29708 dot 1183095662 dot 256 dot realbasic-nug at lists dot realsoftware dot com>
From: Dave Shirk <dave at pamlicosounds dot com>
>
>On Jun 28, 2007, at 9:00 AM, Herd Richard Dr (ENV) wrote:
>
>>  Yes.  The TotalSeconds property of the Date class is a double.
>>  So you can get timing to thousandths of a second.  It's fine on 
>>  Windows
>>  - I use it for timing spectral acquisition - but on OSX, you just
>>  get .000 for the decimal part of the TotalSeconds (see bug report
>>  http://www.realsoftware.com/feedback/viewreport.php?
>>  reportid=bvroufal <https://ueaexchange.uea.ac.uk/exchweb/bin/
>>  redir.asp?URL=http://www.realsoftware.com/feedback/viewreport.php?
>>  reportid=bvroufal>
>>  - even consider signing up for it and doubling the number of votes!
>>
>>  Regards - Richard
>
>Richard,
>
>Thanks for the reply.  I looked at your Report, and just so happens 
>the folks
>at Real responded to it today.  Total seconds as documented is not 
>suppose
>to return any fraction of seconds.  So it works correctly on the Mac.
>
>I still need a way to determine fractions of a second, and see no 
>accurate
>way to accomplish it.
>
>I can fake it - but in this case it will not be good.
>
>Dave

How about something like this:

dim d,dmaster as date, tmaster as double

d=new Date
do
   dmaster=new Date
loop until dmaster.TotalSeconds>d.TotalSeconds
tmaster=Microseconds

At that point you have a date/time (dmaster) pretty close to the 
exact second, and tmaster as the equivalent # of microseconds.

Thereafter (assuming dmaster and tmaster are global), the current 
date/time will be dmaster.Totalseconds + (Microseconds-tmaster)*1E-6, 
accurate to (in theory) a microsecond. In practice a lot worse, but 
probably less than 0.1 seconds.

Paul Rodman
_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives:
<http://support.realsoftware.com/listarchives/lists.html>


<Prev in Thread] Current Thread [Next in Thread>