Here's another issue that I stumbled across. TDbf fails to post a datetime field. Please run this code, it will crash with a SIGFPE in the line where the current date is assigned to the field:
program project1;
{$mode objfpc}{$H+}
uses
SysUtils, Classes, dbf, dbf_common, db, LazFileUtils;
var
Dbf1: TDbf;
begin
ForceDirectories('data');
DeleteFile(AppendPathDelim('data') + 'table1.dbf');
Dbf1 := TDbf.Create(nil);
try
Dbf1.FilePath := AppendPathDelim('data');
Dbf1.TableLevel :=7;
Dbf1.Exclusive := True;
Dbf1.TableName := 'table1.dbf';
// Dbf1.DateTimeHandling := dtDateTime; /// no effect
// Dbf1.DateTimeHandling := dtBDETimeStamp;
With Dbf1.FieldDefs do begin
Add('Date', ftDateTime, 0, false); // no issue with ftDate
end;
Dbf1.CreateTable;
Dbf1.Open;
Dbf1.Append;
Dbf1.FieldByName('Date').AsDateTime := now; // <-- SIGFPE here
Dbf1.Post;
finally
Dbf1.Free;
end;
ReadLn;
end.
Changing the DateTimeHandling mentioned in the manual has no effect. The table, however, is posted without issues if the field is created as a ftDate field - but of course this strips the time part.
Could it be that TDbf does not support date/time fields? But according to
http://wiki.freepascal.org/Lazarus_Tdbf_Tutorial#Adding_fields it does.