No sé si incumplo alguna norma del foro o licencia de Borland, si algún moderador lo sabe, que no dude en eliminar este mensaje e informarme de ello.
El código de la vcl es:
Código Delphi
[-]
const SInvalidDayOfWeekInMonth = '(%d, %d, %d, %d) is not a valid DayOfWeekInMonth quad';
procedure DecodeDayOfWeekInMonth(const AValue: TDateTime; out AYear, AMonth,
ANthDayOfWeek, ADayOfWeek: Word);
var
ADay: Word;
begin
DecodeDate(AValue, AYear, AMonth, ADay);
ANthDayOfWeek := (ADay - 1) div 7 + 1;
ADayOfWeek := DayOfTheWeek(AValue);
end;
function EncodeDayOfWeekInMonth(const AYear, AMonth, ANthDayOfWeek,
ADayOfWeek: Word): TDateTime;
begin
if not TryEncodeDayOfWeekInMonth(AYear, AMonth, ANthDayOfWeek, ADayOfWeek, Result) then
InvalidDayOfWeekInMonthError(AYear, AMonth, ANthDayOfWeek, ADayOfWeek);
end;
function TryEncodeDayOfWeekInMonth(const AYear, AMonth,
ANthDayOfWeek, ADayOfWeek: Word; out AValue: TDateTime): Boolean;
var
LStartOfMonth, LDay: Word;
begin
LStartOfMonth := DayOfTheWeek(StartOfAMonth(AYear, AMonth));
if LStartOfMonth <= ADayOfWeek then
LDay := (ADayOfWeek - LStartOfMonth + 1) + 7 * (ANthDayOfWeek - 1)
else
LDay := (7 - LStartOfMonth + 1) + ADayOfWeek + 7 * (ANthDayOfWeek - 1);
Result := TryEncodeDate(AYear, AMonth, LDay, AValue);
end;
procedure InvalidDayOfWeekInMonthError(const AYear, AMonth, ANthDayOfWeek,
ADayOfWeek: Word);
begin
raise EConvertError.CreateFmt(SInvalidDayOfWeekInMonth, [AYear, AMonth,
ANthDayOfWeek, ADayOfWeek]);
end;
Quizás esta función la tenga ya:
Código Delphi
[-]
function DayOfTheWeek(const AValue: TDateTime): Word;
begin
Result := (DateTimeToTimeStamp(AValue).Date - 1) mod 7 + 1;
end;
Saludos