|
|
|
Zobrazení data a času
|
29.11.2009
|
Úvod
Zobrazení data a času s dosazením nuly k jednociferným hodnotám. Jednotlivé části jdou ve výstupu kombinovat. Vše zasazeno do časovače pro aktualizaci času.
Prvky
Timer1 (Interval: 500)
Label1 (Caption: 00.00.0000 - 00:00:00)
Kód
procedure TForm1.Timer1Timer(Sender: TObject);
VAR
h,m,s:string;//Cas
Hour, Min, Sec, MSec: Word;//Cas
y,mo,d:string;//Datum
Year, Month, Day: Word;//Datum
begin
DecodeDate(Date,Year, Month, Day);
DecodeTime(time, Hour, Min, Sec, MSec);
if Day<10 then d:='0'+inttostr(day) else d:=inttostr(day);
if Month<10 then mo:='0'+inttostr(month) else mo:=inttostr(month);
if Year<10 then y:='0'+inttostr(year) else y:=inttostr(year);
if hour<10 then h:='0'+inttostr(hour) else h:=inttostr(hour);
if min<10 then m:='0'+inttostr(min) else m:=inttostr(min);
if sec<10 then s:='0'+inttostr(sec) else s:=inttostr(sec);
Label1.caption:=' '+d+'.'+mo+'.'+y+' - '+h+':'+m+':'+s;
end;
Varianty
16: Label1.caption:=y+mo+d+h+m+s;
16: Label1.caption:=y+'/'+mo+'/'+d;
|
|
|