[Lazarus] Portable way to get accurate timestamps?

Bo Berglund bo.berglund at gmail.com
Sun Feb 20 10:47:22 CET 2011


In my data acquisition program I also need to timestamp the retrieved
data from the instrument. I want this to be as accurate as possible
and also portable Windows->Linux->Embedded Linux

In Delphi/FPC there are two ways to get a time value that I know of:

GetTickCount gives a value that is in millisecond resolution, but I
don't know how accurate it actually is on the various platforms.

Now() retrieves a TDateTime value, but again I don't know how accurate
it is. Resolution-wise since it is a double it should suffice since it
is based on the year 1900 and we have about 40500 days since then and
thus about 3.500.000.000 seconds. So the double resolution should get
a bit into the decimals of a second. But how many accurate decimals
can be expected? Can I reach millisecond accuracy?

If so, which would be the better way?


-- 
Bo Berglund
Developer in Sweden





More information about the Lazarus mailing list