Here's the task I'm trying to solve and something like an @weekday[date, [before|after], [format]] might be useful:
- Certain reports are due on 1st and 15th of month.
- Certain preparations have to be done 1 business day before.
- The user needs a warning 2 business days before (i.e., "Need to prep tomorrow. Report due on 15th.)
- BUT if the 1st or 15th falls on a weekend the reports are sent the next business day. (E.g., report sent Monday 17th.)
- The warnings have to be on business days--a warning on Saturday the 15th won't be seen.
- "Business" day means Monday-Friday. The function wouldn't handle holidays.
- Reports might have to be filed on or before the 1st and 15th rather than the next business day after.
- January (e.g.) and February would cause problems--you can't just pop up on the 27th, 28th, etc., "1st of Month report due." Users would get annoyed having the "2 day" warning pop up for 4 days and some would start ignoring it.
On the other hand, if the 1st is a Monday, then having it pop up on the 27th might not have it seen for 4 days.
- @weekday[date, [before|after], [format]]
- Echo %@weekday[date] would display date if it is a weekday or -1 (or 0, etc.) if it's not.
- Echo %@weekday[date, "before"] (or more likely, 0 or 1) would display date if it is a weekday. If date is a weekend, it would display the nearest weekday before date.
- You might want to have 2 "format" parameters--one for the format of date and one for the format of the return value.