So after much tinkering, I've been able to implement a rule that now does steps 1-4 with a normally specified date MM-DD-YYYY in the Global Variable GV_TD-G_1, and returns a Unix timestamp into the global variable named GV_TD-U_1 in seconds. This was done the hard way with straight math calcs, and no nice Year(), Month(), Day() type functions available.
If the YYYY = 0000, then the the Unix timestamp is for the current year (at the time the calculation rule is triggered), for the MM-DD-0000 specified. This is so a date can be specified to calculate for a very specific date in if YYYY is included, and therefore it only needs to be calculated once, or every year on MM-DD if YYYY = 0000. For YYYY=0000, then you would just trigger the rule to calculate at the beginning of each year, and it should run perpetually. The date must be in the form MM-DD-YYYY, and include each section or the token calc in the rule errors out of range, and nothing else calculates
Now that a target date is stored in a variable, steps 5-10 should be possible, at least for completely specified dates.
The next step is to try to calculate Unix timestamps for the Nth day of the week in a month.
I have to say implementing this in RM was a bit painful with the interface mechanics, but the calcs use fairly simple operators, so it was possible to pull off. It would definitely be easier if the RM logic stored this variable for a set trigger event on its own. The logic for the math came from this website: chrono-Compatible Low-Level Date Algorithms plus some adjustment to get to work well first in Excel, then in RM.
I tested this for a long range of dates from 1-1-1901 to 12-31-2100+ in Excel, and the math seems to hold. So this should be a durable formula to implement, but there will be a Unix timestamp issue in 2038 if there is no switch to 64 bit...
For example, if I enter:
05-20-2025
The Unix timestamp returns:
1747699200
Which validates as the Unix timestamp for:
Tue, 20 May 2025 00:00:00
As verified by this site: https://www.textmagic.com/free-tools/timestamp-converter
Right now I have the calculation rule set to trigger on the change in the GV_TD-G_1 variable, which means, I can see the Unix timestamp returned in the Global Variables List as soon as I change the Target Date.
Global Variables:
Local Variables:
Rule:
Would be happy to hear is anyone has a simpler way to do this without altering RM.