unit  Forma;
interface
uses
 SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics,  Controls,
 Forms, Dialogs, StdCtrls;
type
 TForma1 = class(TForm)
 Edit1: TEdit;
 Label1: TLabel;
 Label2: TLabel;
 Label3: TLabel;
 GetWeekBtn: TButton;
 Label4: TLabel;
 procedure GetWeekBtnClick(Sender: TObject);
 procedure FormCreate(Sender: TObject);
 private
 { Private declarations }
 Function HowManyDays(pYear,pMonth,pDay:word):integer;
 public
 { Public declarations }
 end;
var
 Forma1: TForma1;
implementation
{$R *.DFM}
Uses Inifiles;
procedure  TForma1.FormCreate(Sender: TObject);
var        WinIni:TInifile;
begin
 WinIni:=TIniFile.Create('WIN.INI');
 WinIni.WriteString('intl','sShortDate','MM/dd/yyyy');
 WinIni.Free;
end;
Function  TForma1.HowManyDays(pYear,pMonth,pDay:word):integer;
var       Sum:integer;
 pYearAux:word;
begin
 Sum:=0;
 if pMonth>1  then  Sum:=Sum+31;
 if pMonth>2  then  Sum:=Sum+28;
 if pMonth>3  then  Sum:=Sum+31;
 if pMonth>4  then  Sum:=Sum+30;
 if pMonth>5  then  Sum:=Sum+31;
 if pMonth>6  then  Sum:=Sum+30;
 if pMonth>7  then  Sum:=Sum+31;
 if pMonth>8  then  Sum:=Sum+31;
 if pMonth>9  then  Sum:=Sum+30;
 if pMonth>10 then  Sum:=Sum+31;
 if pMonth>11 then  Sum:=Sum+30;
 Sum:=Sum + pDay;
 if ((pYear - (pYear div 4)*4)=3D0) and
 (pMonth>2)then
 inc(Sum);
 HowManyDays:=Sum;
end;   {  HowManyDays } 
procedure TForma1.GetWeekBtnClick(Sender:  TObject);
var
 ADate: TDateTime;
 EditAux:String;
 Week,year,month,day:Word;
begin
 EditAux:=Edit1.Text;
 ADate := StrToDate(EditAux);
 Label1.Caption := DateToStr(ADate);
 DecodeDate(Adate,Year,Month,Day);
 Case DayOfWeek(ADate) of
 1: Label4.Caption:='Воскресенье';
 2: Label4.Caption:='Понедельник';
 3: Label4.Caption:='Вторник';
 4: Label4.Caption:='Среда';
 5: Label4.Caption:='Четверг';
 6: Label4.Caption:='Пятница';
 7: Label4.Caption:='Суббота';
 end
 Week:=(HowManyDays(year,month,day) div 7) +1;
 Label3.Caption:='Неделя No.  '+IntToStr(Week);
end;
end.