كيفية حساب عدد الساعات بين تاريخين محددين
#13
للفائدة فقظ مثال رائع
كود :
unit NP; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, ExtCtrls, StdCtrls, ShellApi, XpMan; type TMainFrm = class(TForm) Time: TLabel; Working: TLabel; T: TTimer; lb: TLabel; tx7: TLabel; procedure TTimer(Sender: TObject); procedure lbClick(Sender: TObject); private public end; var MainFrm: TMainFrm; implementation {$R *.dfm} function IntToStr(I: Longint): String; var S: string[11]; begin Str(I, S); IntToStr := S; end; procedure TMainFrm.TTimer(Sender: TObject); var count, days, min, hours, seconds: Longint; begin count := GetTickCount(); count := count div 1000; days := count div (24 * 3600); If days > 0 Then count := count - (24 * 3600 * days); hours := count div 3600; If hours > 0 Then count := count - (3600 * hours); min := count div 60; seconds := count Mod 60; Time.caption := IntToStr(days) + ' Days ' + IntToStr(hours) + ' hours ' + IntToStr(min) + ' minutes ' + IntToStr(seconds) + ' seconds '; end;


كود :
unit NP; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls, XpMan, ShellApi; type TMainFrm = class(TForm) Timer: TTimer; tx1: TLabel; tx2: TLabel; tx3: TLabel; tx4: TLabel; tx5: TLabel; tx6: TLabel; tx7: TLabel; tx8: TLabel; tx9: TLabel; tx10: TLabel; tx12: TLabel; tx11: TLabel; procedure TimerTimer(Sender: TObject); procedure tx12Click(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } public { Public declarations } end; var MainFrm: TMainFrm; implementation {$R *.dfm} procedure TMainFrm.TimerTimer(Sender: TObject); begin tx1.Caption := FormatDateTime('hh:mm:ss', time()); tx2.Caption := DateToStr(Now); tx3.Caption := FormatDateTime('dddd', date()); tx4.Caption := FormatDateTime('am/pm', time()); tx5.Caption := FormatDateTime('dd', date()); tx6.Caption := FormatDateTime('dddd', date()); tx7.Caption := FormatDateTime('ddd', date()); tx8.Caption := FormatDateTime('zzz', time()); tx9.Caption := FormatDateTime('nn:ss', time()); tx10.Caption := FormatDateTime('tt', time()) + #$A#$D ; ShowMessage( FormatDateTime('am/pm', time()) + #$A#$D + FormatDateTime('ampm', time()) + #$A#$D + FormatDateTime('a/p', time()) + #$A#$D + FormatDateTime('ap', time()) + #$A#$D + FormatDateTime('e', date()) + #$A#$D + FormatDateTime('ee', date()) + #$A#$D + FormatDateTime('g', date()) + #$A#$D + FormatDateTime('gg', date()) + #$A#$D + FormatDateTime('yyy', date()) + #$A#$D + FormatDateTime('yy', date()) + #$A#$D + FormatDateTime('mm', date()) + #$A#$D + FormatDateTime('dd', date()) + #$A#$D + FormatDateTime('mmm', date()) + #$A#$D + FormatDateTime('ddd', date()) + #$A#$D + FormatDateTime('mmmm', date()) + #$A#$D + FormatDateTime('dddd', date()) + #$A#$D + FormatDateTime('h', time()) + #$A#$D + FormatDateTime('hh', time()) + #$A#$D + FormatDateTime('n', time()) + #$A#$D + FormatDateTime('nn', time()) + #$A#$D + FormatDateTime('s', time()) + #$A#$D + FormatDateTime('ss', time()) + #$A#$D + FormatDateTime('z', time()) + #$A#$D + FormatDateTime('zzz', time()) + #$A#$D + FormatDateTime('m', date()) + #$A#$D ) ; end; procedure TMainFrm.tx12Click(Sender: TObject); begin ShellExecute(Handle, nil, 'http://www.krinkels.ru/', nil, nil, Sw_ShowNormal); end; procedure TMainFrm.FormDestroy(Sender: TObject); begin Timer.Free; end; end.
الرد


الردود في هذا الموضوع
كيفية حساب عدد الساعات بين تاريخين محددين - بواسطة cargem - 03-08-2011, 10:13 PM

التنقل السريع :


يقوم بقرائة الموضوع: بالاضافة الى ( 1 ) ضيف كريم