Using Delphi, I need a function to evaluate the current date and see if it’s, for example, the Third Sunday of the month, etc.
In pseudocode:
function IsFirst(const CurrentDateTime: TDateTime; const Day: Word): Boolean;
/// Day can be 1-7 (monday to sunday)
begin
Result:= ??
end;
Another function would be needed to calculate the Second, Third, Forth and Last of the month. DateUtils seems to have nothing like that. Any ideas?
This function is what you need:
The equivalent function for the second occurrence is:
I’m sure you can fill out the details for third, fourth and fifth. You may prefer to write a single general function like this: