For Newbie

Tuesday, 15 November 2011

Check whether the time is AM or PM by Delphi



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;

Share on Facebook
Share on Twitter
Share on Google+

Related : Check whether the time is AM or PM by Delphi