TryEncodeDayOfWeekInMonth function
Encode a year, month, week, day of week triplet to a
TDateTime value.
Declaration
function TryEncodeDayOfWeekInMonth(const AYear: Word;
const AMonth: Word;
const ANthDayOfWeek: Word;
const ADayOfWeek: Word;
out AValue: TDateTime): BooleanArguments
AYear | Year. |
AMonth | Month in year. |
ANthDayOfWeek | Day of week occurrence. |
ADayOfWeek | Day of week. |
AValue | Resulting TDateTime value. |
Function result
True if the encoding was successful,
False if not.Description
EncodeDayOfWeekInMonth encodes
AYear,
AMonth,
ADayOfweek and
ANthDayOfweek to a valid date stamp and returns the result in
AValue.
ANthDayOfweekis the N-th time that this weekday occurs in the month, e.g. the
third Saturday of the month.
The function returns True if the encoding was successful,
False if any of the values is not in range.
See also
Example: ex106
Program Example105;
{ This program demonstrates the DecodeDayOfWeekInMonth function }
Uses SysUtils,DateUtils;
Var
Y,M,NDoW,DoW : Word;
D : TDateTime;
Begin
DecodeDayOfWeekInMonth(Date,Y,M,NDoW,DoW);
If TryEncodeDayOfWeekInMonth(Y,M,NDoW,DoW,D) then
begin
Write(DateToStr(D),' is the ',NDow,'-th ');
Writeln(formatdateTime('dddd',D),' of the month.');
end
else
Writeln('Invalid year/month/NthDayOfweek combination');
End.An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
