[Remind-Fans] Dynamically calculating the advanced-warning

Tim Chase remind at tim.thechases.com
Wed Dec 11 11:38:41 EST 2019


There are some folks that I usually only see on Sundays and would like
advanced warning if their birthday is in the following week so I can
wish them a happy birthday.  However I was hoping to only get the
notification on Sunday, so my thought was something like

  REM Dec 12 ++[iif(wkdaynum($U) == 0, wkdaynum($T), 0)] \
    MSG %"Pat's birthday%"%

("if today is Sunday, then give me wkdaynum(their actual birthday)
days of advance notice, otherwise, don't give me advance notice")

However $T isn't available at that point yet.

The closest hack I've been able to come up with is the following:

  FSET bday(dt) dt + iif( \
    wkdaynum($U) == 0, \
    " ++" + coerce("STRING", wkdaynum(evaltrig(dt, $U))), \
    "")
  REM [bday("Dec 12")] MSG %"Pat's birthday %c%"%

which seems to work well enough but relies on expression-pasting
allowing the trigger-date PLUS the advanced-warning to be generated
from the same string.  AFAICT, this is legit, but wanted to make sure
this wasn't an abuse of something that I should avoid.  The man-page
gives warnings about not using expression-pasting for the first
command (the "REM") or the message type (MSG/MSF/CAL/...) so I think
this is fair game.

Thoughts?  Is there a better way to dynamically set the number of
advanced-warning days based on the trigger date?

(and if anybody finds this useful, feel free to filch it)

-tim












More information about the Remind-fans mailing list