Cek apakah waktu adalah AM atau PM.
Deklarasi fungsi :
const
WAKTU_AM = 1;
WAKTU_PM = 2;
function CekWaktuAMPM(d: TDateTime): Byte;
var
fd: Real;
begin
fd:= Frac(d);
if fd >= 0.5 then Result:= WAKTU_PM else Result:= WAKTU_AM;
end;
WAKTU_AM = 1;
WAKTU_PM = 2;
function CekWaktuAMPM(d: TDateTime): Byte;
var
fd: Real;
begin
fd:= Frac(d);
if fd >= 0.5 then Result:= WAKTU_PM else Result:= WAKTU_AM;
end;
Contoh implementasi :
procedure TForm1.Button1Click(Sender: TObject);
var
sAMPM: String;
begin
case CekWaktuAMPM(Now) of
WAKTU_AM: sAMPM:= 'AM';
WAKTU_PM: sAMPM:= 'PM'
end;
ShowMessage(sAMPM);
end;
var
sAMPM: String;
begin
case CekWaktuAMPM(Now) of
WAKTU_AM: sAMPM:= 'AM';
WAKTU_PM: sAMPM:= 'PM'
end;
ShowMessage(sAMPM);
end;
0 comments:
Post a Comment