Tuesday, 15 November 2011
Home »
Tips and Trick Delphi
» Check whether the time is AM or PM by Delphi
Check whether the time is AM or PM by Delphi
To Share | Tuesday, 15 November 2011
Function declaration:
const
time_AM = 1;
time_PM = 2;
timeAMPMcheck function (d: TDateTime): Byte;
var
fd: Real;
begin
fd: = frac (d);
if fd> = 0.5 then Result: = timeWAKTU_PM else Result: = time_AM;
end;
Example of implementation:
procedure TForm1.Button1Click (Sender: TObject);
var
sAMPM: String;
begin
case timeAMPMcheck (Now) of
time_AM: sAMPM: = 'AM';
time_PM: sAMPM: = 'PM'
end;
ShowMessage (sAMPM);
end;
No comments:
Post a Comment