Subject Re: [firebird-support] Re: Record versioning/timestamping
Author Dimitry Sibiryakov
On 21 Dec 2004 at 17:50, Greg At ACD wrote:

>Therefore I would look at doing something similar to you and implement
>my own routines; the millisecond portion is important for us, and I'd
>rather find a way to deal with it rather than use another DB solution
>(there are many aspects of Firebird that I like; this is the first
>major roadblock I've come across).
>
>Of course I do need to ask... is such an implementation already
>publicly available (so to avoid the reinventing of the wheel...)?

My memory failed me too often recently... I sent my components to
somebody (probably, UIB guis), so these procedures may be published.
But they actually are very simple:

const
IBTimeDivider=24*60*60*10000;
IBDateOffset=-15018;

Procedure TFIBParam.SetAsDateTime;
begin
IsNull := False;
Case FData^.sqltype and not 1 of
SQL_TIMESTAMP : With PISC_TIMESTAMP(Buffer)^ do
begin
timestamp_date := Trunc(Value)-IBDateOffset;
timestamp_time :=
Round(IBTimeDivider*Abs(Frac(Value)));
end;
...
end;

Function TFIBField.GetAsDateTime;
begin
Result := 0;
If not IsNull then
Case FData^.sqltype and not 1 of
SQL_TIMESTAMP : With PISC_TIMESTAMP(Buffer)^ do
begin
Result := timestamp_date+IBDateOffset;
If Result<0 then
Result := Result-timestamp_time/IBTimeDivider
else
Result := Result+timestamp_time/IBTimeDivider;
end;
...
end;

>Will FB 2.0 provide a new isc_decode_timestamp() function to support
>milliseconds (and similarly for encoding)...?

No. Is there a standard and portable C type, supporting
milliseconds?
--
SY, Dimitry Sibiryakov.