IsValidDateMonthWeek function
Check whether a given year/month/week/day of the week combination is a valid day.
Declaration
function IsValidDateMonthWeek(const AYear: Word; const AMonth: Word;
const AWeekOfMonth: Word;
const ADayOfWeek: Word): BooleanArguments
AYear | Year. |
AMonth | Month of the year. |
AWeekOfMonth | Week of the month. |
ADayOfWeek | Day in the week. |
Function result
True if the given combination is a valid date,
False otherwise.Description
IsValidDateMonthWeek returns
True if
AYear,
AMonth
AWeekOfMonth and
ADayOfWeek form a valid date indication,
or
False otherwise.
AYear must be in the range 1..9999 to be valid.
The AWeekOfMonth,ADayOfWeek values are checked to see whether
the combination falls within the valid range of weeks for the
AYear,AMonth combination.
See also
Example: ex11
Program Example11;
{ This program demonstrates the IsValidDateMonthWeek function }
Uses SysUtils,DateUtils;
Var
Y,W,D : Word;
B : Boolean;
Begin
For Y:=2000 to 2004 do
begin
B:=True;
For W:=4 to 6 do
For D:=1 to 7 do
If B then
begin
B:=IsValidDateMonthWeek(Y,12,W,D);
If Not B then
if (D=1) then
Writeln('December ',Y,' has exactly ',W,' weeks.')
else
Writeln('December ',Y,' has ',W,' weeks and ',D-1,' days.');
end;
end;
End.An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
