Hi! I think the methods GetDayOfWeek(), GetMonth(), and GetDay() are the tools you're looking for. They return 1-7, 1-12, and 1-31 respectively.
I haven't tested any of this, but how I would go about it is to start by creating a table of all the days in each month, something like this:
DaysInMonth = 31; // January
DaysInMonth = 28; // February
DaysInMonth = 31; // March
DaysInMonth = 30; // April
DaysInMonth = 31; // May
DaysInMonth = 30; // June
DaysInMonth = 31; // July
DaysInMonth = 31; // August
DaysInMonth = 30; // September
DaysInMonth = 31; // October
DaysInMonth = 30; // November
DaysInMonth = 31; // December
This only needs to be done once, so I would put it in it's own block. After that it's a matter of checking to see if it's Friday, if it is then check if there's less than a week until the end of the month. To get "days remaining" just reference the table using the current month number and subtract off the current date.
if (GetDayOfWeek() == 5) then
if ((DaysInMonth[GetMonth()] - GetDay()) < 7) then
// trigger that thing to run
I think the next leap year where February 29th is a Friday isn't until 2036, at which point it will give (28 - 29) = -1, which is still < 7 so this shouldn't break, but I can't say for sure...
How exactly you want to do the repetition, whether though a loop, delay block, time check, or something of that sort will depend on your application. Here's a little chart I threw together to demonstrate what it might look like:
Again, this is sort of a throw together, it has not been tested thoroughly (or, uh, at all) but I hope it helps!