uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls, Buttons, Grids, Windows;
......
Function Calendario: String;
var
frstDay,toDay : TDateTime;
week, BS: Integer;
WK, DD, MM, AA, S_F: String;
Yr, Mnth, Day: Word;
stSystemTime : TSystemTime;
Begin
Result := '';
WK := IntToStr(DayOfWeek(Now)); MM := FormatDateTime('mm', Now);
DecodeDate(Date, Yr, Mnth, Day);
if IsLeapYear(Yr) then BS := 366 Else BS := 365;
If WK = '1' Then WK := 'Domingo';
If WK = '2' Then WK := 'Lunes';
If WK = '3' Then WK := 'Martes';
If WK = '4' Then WK := 'Miercoles';
If WK = '5' Then WK := 'Jueves';
If WK = '6' Then WK := 'viernes';
If WK = '7' Then WK := 'sabado';
If MM = '01' Then MM := 'enero';
If MM = '02' Then MM := 'febrero';
If MM = '03' Then MM := 'marzo';
If MM = '04' Then MM := 'abril';
If MM = '05' Then MM := 'mayo';
If MM = '06' Then MM := 'junio';
If MM = '07' Then MM := 'julio';
If MM = '08' Then MM := 'agosto';
If MM = '09' Then MM := 'septiembre';
If MM = '10' Then MM := 'octubre';
If MM = '11' Then MM := 'noviembre';
If MM = '12' Then MM := 'diciembre';
Windows.GetLocalTime( stSystemTime );
S_F := DateTimeToStr( SystemTimeToDateTime( stSystemTime ) );
S_F := Copy(S_F, 3, 1);
Result := Uppercase(MM) + '|';
Result := Result + FormatDateTime('dd', Now) + '|';
Result := Result + WK + '|';
frstDay := StrToDate('01' + S_F + '01' + S_F + FormatDateTime('yy', Now));
toDay := StrToDate(FormatDatetime('dd', Now) + S_F + FormatDatetime('mm', Now) + S_F + FormatDatetime('yy', Now));
week := Trunc((toDay - frstDay) / 7) + 1;
Result := Result + 'Semana ' + IntToStr(week) + '|';
Result := Result + 'día ' + IntToStr(Trunc(toDay - frstDay) + 1) + ', faltan ' + IntTostr(BS - Trunc(toDay - frstDay) - 1) + '|';
End;
Para llamar a la función:
P := Calendario;
Para visualizar los datos:
Label31.Caption := Copy(P, 1, Pos('|', P) - 1);
P := Copy(P, Pos('|', P) + 1, Length(P) - Pos('|', P));
Label32.Caption := Copy(P, 1, Pos('|', P) - 1);
P := Copy(P, Pos('|', P) + 1, Length(P) - Pos('|', P));
Label33.Caption := Copy(P, 1, Pos('|', P) - 1);
P := Copy(P, Pos('|', P) + 1, Length(P) - Pos('|', P));
Label34.Caption := Copy(P, 1, Pos('|', P) - 1);
P := Copy(P, Pos('|', P) + 1, Length(P) - Pos('|', P));
Label35.Caption := Copy(P, 1, Pos('|', P) - 1);
P := Copy(P, Pos('|', P) + 1, Length(P) - Pos('|', P));