(You can actually delete the overridden destructor for TMyDateTime, and its implementation, since it is useless, but harmless).
Try this. Start a new Lazarus project, and save it and name it appropriately in a new directory. Check that the empty project compiles and displays an empty form OK. Copy dateTimeUnit.pas (or whatever you have called the unit that declares TMyDateTime) to the new project directory.
Add a button and a button OnClick handler, and an OnCreate handler and and OnDestroy handler for the project's main form, and add dateTimeUnit to the uses clause.
Complete the implementations of the handlers as follows:
unit mainDateTime; // or whatever you have called it
{$mode objfpc}{$H+}
interface
uses
SysUtils, Forms, Dialogs, StdCtrls,
dateTimeUnit; // or whatever you called it
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
myDT: TMyDateTime;
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
ShowMessage(MyDT.GetDateTimeAsString);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MyDT:= TMyDateTime.Create(Now);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
myDT.Free;
end;
end.
If that works OK, then add the other buttons and handlers one by one, testing as you go until you have the full project working. Delete the first project, which has something wrong somewhere, but without seeing it we don't know where.