Wednesday, January 5, 2011

Cek Waktu AM-PM

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;
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;

0 comments:

Post a Comment

Twitter Delicious Facebook Digg Stumbleupon Favorites More

 
Design by Kang Iwan K-sev | Thank's for your visit To My Site - Ridwan Mulyana | Cibeureum