Hi everyone,
I want to convert TFloatSpinEdit value to time. By time, I don't mean time of the day, I mean that if I enter 45.5 into the TFloatSpinEdit, the application will return 45:30:00.
This is what I have so far, but I fear that I have used the wrong function - StrToTime - which is part of TDateTime (I don't want time of the day). This is what I have so far:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls,
Spin;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
FloatSpinEdit1: TFloatSpinEdit;
procedure Button1Click(Sender: TObject);
private
public
end;
var
Form1: TForm1;
myTime : TDateTime;
TimeString:string;
TimeDec: real;
implementation
{$R *.lfm}
{ TForm1 }
procedure TForm1.Button1Click(Sender: TObject);
begin
TimeDec := FloatSpinEdit1.Value;
TimeString:=FloatToStr(TimeDec);
myTime := StrToTime(TimeString);
ShowMessage('myTime = '+TimeToStr(myTime));
end;
end.
This code doesn't allow for a value more than 23, and it doesn't allow for decimals either.
Does anybody know of a possible solution?
Thanks in advance,
laznoob