[Remind-Fans] help with "garbage day"

Paul Pelzl pelzlpj at eecs.umich.edu
Thu Jan 25 20:25:23 EST 2007


On Thu, Jan 25, 2007 at 04:25:27PM -0800, brian hammond wrote:
> When looking for the trash day, we want the first non-omitted day in a
> work week, then the day after that.  So we have to find a Mon and move
> AFTER it if needed.  Since the latest the trash day can be is Wed of a
> week, we only have to look 2 days back at most to find Monday.  If
> today() happens to be Thu, then we'd be scheduling the trash day for
> the next week since -2 from Thu is only Tue.
> 
> Some of your other offsets confused me a bit but after checking what I
> thought they should (or could be I guess), I got different numbers
> that seem to work.  Mine are simpler a little tighter.  The latest
> paper day can be is Thu of a week.  We find Mon (at most -3 away),
> then the next day (moving AFTER omitted days) to find trash day.  And
> again for paper day.  So you used -4 which also works since it would
> just start at Sun if today() is Thu.

Sounds like you've decoded things about right.  And indeed, there is
some flexibility in how you choose the scanning offsets.  I tried to
allow for a couple holidays within the same week, which explains why my
offsets were a bit larger than they had to be.


> I have another related query that I was waiting on but now that I
> understand SCANFROM, it wasn't that hard to figure out.  I'm sure
> there's a simpler way that I don't know.  "Bulk trash" day is the 2nd
> Fri of each month.  If there's a holiday in any work day of the 2nd
> week of the month, there's no bulk trash day that month.
> 
> # Find first non-omitted day in this week.  The furthest we can be 
> # from today() is 4 days back (i.e. when today() is Fri).
> 
> REM Mon AFTER SCANFROM [trigger(today()-4)] SATISFY 1
> 
> # If the triggered date is Mon then the AFTER clause never kicked
> # in which means there were no holidays this week.  When there's
> # no holidays this week, we can try to satisfy the trigger Fri 8
> # which means the first Fri after the 8th of the month which is 
> # the 2nd Fri of the month.
> 
> IF WKDAYNUM(TRIGDATE()) == 1
>   REM Fri 8 +2 MSG take out bulk trash %b
> ENDIF

This will only pick up on omitted Mondays.  So if you have a holiday on
Tuesday it will still generate a reminder on Friday.

Here's a (lengthy) one-liner that searches forward for the next
occurrence of a Friday that falls in the second week of a month and also
satisfies the condition on holidays:

REM Fri 8 +2 SATISFY [!isomitted(trigdate()-4) && !isomitted(trigdate()-3) && !isomitted(trigdate()-2) && !isomitted(trigdate()-1) && !isomitted(trigdate())] MSG take out bulk trash

In general, I find that using SCANFROM often leads to unforeseen
behavior that is tricky to debug--"here be dragons" and all that.  IMO,
avoid SCANFROM when possible.

Paul





More information about the Remind-fans mailing list