@gwp1 said in Lights on UNTIL fourth Thursday of the month:
Am I implementing the latch because there is a availability of multiple Friday's in that 22-EOM after range and latching the extra layer of weekday fourth vs any Friday is what caps the grouped sub-range from going beyond that fourth Friday?
No, you're using latch because 6 of 7 days of the week aren't Fridays, and as many as 8 days, including another Friday, or as few as 2 with no Friday, may follow the fourth Friday in November of any given year. So once we encounter the fourth Friday, we want to continue to hold that condition state on Saturday, Sunday, Monday, and every other day that may follow through the end of the month. The latch takes care of that easily.
I know @LibraSun is into expressions, so another possible solution is to use expressions to gin up the timestamp for midnight on the 22nd day of November (the earliest day of the month a fourth Friday could be) of the current year, and then get its day of the week. Knowing that Friday is weekday index 5, you can increment the date to figure out when the fourth Friday occurs. For example, if 11/22 is already weekday 5, you're on target and no offset is needed (that date is the fourth Friday). But if 11/22 is weekday 1 (Monday), you need to add 4 (days, 5-1) to the timestamp to get it to a Friday. I'll leave what to do if 11/22 is a Saturday (weekday index 6) as an exercise for the reader. 🙂 Once you've incremented the date, just compare it to the current time to see if you're on or before it.