Get Sunday and Monday days of the current week  

Send By: Radikal (Q3 Team)
Web : http://www.q3.nu
Email: radikal@q3.nu
Date: 14/01/04

Tip accessed 519 times

 


Useful for example to limit a MonthCalendar to the current week

 procedure TForm1.MonthCalendar1GetMonthInfo(Sender: TObject;
   Month: Cardinal; var MonthBoldInfo: Cardinal);

   function LunesDeEstaSemana: TDateTime;
   {Devuelve el Lunes de la semana en curso}
   {Returns the Monday of the current week}
   var
     Hoy : integer;
   begin
     Hoy:=DayOfWeek(Now);
     if Hoy = 1 then Result:=Now-6
                else Result:=Now-(Hoy-2);
   end;

   function DomingoDeEstaSemana: TDateTime;
   {Devuelve el Domingo de la semana en curso}
   {Returns the Sunday of the current week}
   var
     Hoy : integer;
   begin
     Hoy:=DayOfWeek(Now);
     if Hoy=1 then Result:=Now
              else Result:=Now+(8-Hoy);
   end;

 begin
   MonthCalendar1.MinDate:=LunesDeEstaSemana;
   MonthCalendar1.MaxDate:=DomingoDeEstaSemana;
 end;