유돌이

calendar

1 2
3 4 5 6 7 8 9
10 11 12 13 14 15 16
17 18 19 20 21 22 23
24 25 26 27 28 29 30

Notice

2019. 9. 25. 11:26 델파이



    

 

unit Unit1;

 

interface

 

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls;

 

type
  TForm1 = class(TForm)
    Timer1: TTimer;
    Edit1: TEdit;
    Button1: TButton;
    Edit2: TEdit;
    Button2: TButton;
    Edit3: TEdit;
    Edit4: TEdit;
    Label1: TLabel;
    Label2: TLabel;
    Edit5: TEdit;
    Label3: TLabel;
    procedure Timer1Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
    EditTime1 : TDateTime;
    EditTime2 : TDateTime;
    EditTime3 : TDateTime;
    EditTime4 : TDateTime;
  public
    { Public declarations }
  end;

 

var
  Form1: TForm1;

 

implementation

 

{$R *.dfm}

 

// 날짜 차이 계산
function DayBetween(Date1, Date2: TDateTime): integer;
var
   Day1, Day2 : TDateTime;
begin
   //Day1 := StrToDate( `2009-12-31` );
   //Day2 := StrToDate( `2009-11-30` );

   Day1 := StrToDate( FormatDateTime('YYYY-MM-DD', Date1) );
   Day2 := StrToDate( FormatDateTime('YYYY-MM-DD', Date2) );

   Result := integer( Trunc( Day1 - Day2 ));
end;

 

procedure TForm1.Timer1Timer(Sender: TObject);
begin

  // 현재 시간
  EditTime1  := Now;
  Edit1.Text := FormatDateTime('YYYY-MM-DD  HH:NN:SS', EditTime1);
end;

 

procedure TForm1.Button1Click(Sender: TObject);
begin

  // 들어온 시간
  EditTime2  := EditTime1;
  Edit2.Text := Edit1.Text;
end;

 

procedure TForm1.Button2Click(Sender: TObject);
begin

  // 나간 시간
  EditTime3  := EditTime1;
  Edit3.Text := Edit1.Text;

 

  // 주차한 시간

  EditTime4  := EditTime3 - EditTime2;
  Edit4.Text := FormatDateTime('HH:NN:SS', EditTime4);

 

  // 날짜 차이

  Edit5.Text := IntToStr( DayBetween(EditTime3, EditTime2) );
end;

 

end. 

posted by 유돌이