Subject | Re: Pascal UDF passing timestamps/strings |
---|---|
Author | sir_wally_lewis |
Post date | 2011-10-11T07:22Z |
so these functions look like:
procedure fbdatetopascaldate( ib_datetime : PISC_QUAD; VAR pscl_dt : TDATETIME );
var
tm_date:Tm;
begin
init_tm(tm_date);
isc_decode_date(ib_datetime,@tm_date);
pscl_dt := EncodeDate(tm_date.tmYear + 1900, tm_date.tm_mon + 1, tm_date.tm_mday )
+ EncodeTime(tm_date.tm_hour, tm_date.tm_min, tm_date.tm_sec, 0 );
end;
procedure pascaldatetofbdate( pscl_dt : TDATETIME; VAR ib_datetime : PISC_QUAD );
var
tm_date:Tm;
yyyy,mm,dd,hh,nn,ss,zzz : word;
begin
init_tm(tm_date);
decodedate(pscl_dt,yyyy,mm,dd);
decodetime(pscl_dt,hh,nn,ss,zzz);
tm_date.tm_min := nn;
tm_date.tm_hour := hh
tm_date.tm_sec := ss;
tm_date.tm_mday := dd;
tm_date.tm_mon := mm - 1;
tm_date.tm_year := yyyy - 1900;
Creatsomemagicalmemoryforthepointer;
isc_encode_date(@tm_date,ib_dateTime);
end;
Don't know how to create the memory though.
I use this function for strings:
function MakeResultString(Source, OptionalDest: PChar; Len: DWORD): PChar;
begin
result := OptionalDest;
if( Len = 0 )then
Len := StrLen(Source) + 1;
if( result = nil )then
result := ib_util_malloc(Len);
if( Source <> result )then
begin
if(Source = nil)or( Len = 1 )then
result[0] := #0
else
Move(Source^, result^, Len);
end;
end;
Kind Regards,
Robert.
procedure fbdatetopascaldate( ib_datetime : PISC_QUAD; VAR pscl_dt : TDATETIME );
var
tm_date:Tm;
begin
init_tm(tm_date);
isc_decode_date(ib_datetime,@tm_date);
pscl_dt := EncodeDate(tm_date.tmYear + 1900, tm_date.tm_mon + 1, tm_date.tm_mday )
+ EncodeTime(tm_date.tm_hour, tm_date.tm_min, tm_date.tm_sec, 0 );
end;
procedure pascaldatetofbdate( pscl_dt : TDATETIME; VAR ib_datetime : PISC_QUAD );
var
tm_date:Tm;
yyyy,mm,dd,hh,nn,ss,zzz : word;
begin
init_tm(tm_date);
decodedate(pscl_dt,yyyy,mm,dd);
decodetime(pscl_dt,hh,nn,ss,zzz);
tm_date.tm_min := nn;
tm_date.tm_hour := hh
tm_date.tm_sec := ss;
tm_date.tm_mday := dd;
tm_date.tm_mon := mm - 1;
tm_date.tm_year := yyyy - 1900;
Creatsomemagicalmemoryforthepointer;
isc_encode_date(@tm_date,ib_dateTime);
end;
Don't know how to create the memory though.
I use this function for strings:
function MakeResultString(Source, OptionalDest: PChar; Len: DWORD): PChar;
begin
result := OptionalDest;
if( Len = 0 )then
Len := StrLen(Source) + 1;
if( result = nil )then
result := ib_util_malloc(Len);
if( Source <> result )then
begin
if(Source = nil)or( Len = 1 )then
result[0] := #0
else
Move(Source^, result^, Len);
end;
end;
Kind Regards,
Robert.