[Remind-Fans] Creating events that repeat every N days for a couple days

Tim Chase remind at tim.thechases.com
Thu Dec 5 14:08:55 EST 2019


I had cause to revisit this recently (sorry for the TOFU reply but
the details of the original request are largely immaterial) to try
and put together a menstrual calendar and I think I found a solution
this time.

So just in case anybody else has cause for events that repeat every
"per_frequency" (at least 10 based on $MaxSatIter requirements) days
from "per_start" date and last for "per_duration" days and you want
"per_warn" days worth of notice the event is coming, hopefully this
proves useful to you:

  # update these 6 variables according to your needs
  SET per_start      date(2019, 12, 1)
  SET per_duration   5
  SET per_frequency  28
  SET per_warn       4
  SET per_warn_msg   "Warning message"
  SET per_event_msg  "Event message"

  # simplify off-by-one adjustments
  SET per_duration1 per_duration - 1
  # set MaxSatIter to the min but save it so we can restore it
  SET per_old_MaxSatIter $MaxSatIter
  SET $MaxSatIter per_frequency
  # find the last day of the event
  SATISFY [($T - (per_start + per_duration1)) % per_frequency == 0]
  IF trigvalid()
      # should be valid, but just to be sure
      SET per_end_date trigdate()
      REM [per_end_date] ++[per_duration1 + per_warn] \
          MSG %"[iif( \
              $T - $U > per_duration1, \
              per_warn_msg, per_event_msg) \
              + " " \
              + coerce("STRING", $T - (per_duration1)) \
              + " through " \
              + coerce("STRING", $T) \
              ]%"%
  ENDIF
  # restore MaxSatIter
  SET $MaxSatIter per_old_MaxSatIter

At least it Works For Me(tm), and might work for you too.

-tim

On 2019-02-05 10:03, Tim Chase wrote:
> I have a couple house-keeping chores that take me several days to do
> and are supposed to fall on an N-day schedule but I'm having trouble
> defining such a repetition in remind.  Ideally I'd get a "be
> prepared" reminder for a day or two ahead (like "+2"), too.
> 
> My attempt to create some sort of "magic()" function has been
> unsuccessful:
> 
>   SET BackupStart date(2019, 2, 5)
>   SET BackupDuration 3
>   SET BackupPeriodicity 90
>   SET WarningDays 2
> 
>   REM [magic(BackupStart, BackupPeriodicity, 0)] \
>     ++[WarningDays] \
>     THROUGH [magic(BackupStart, BackupPeriodicity, BackupDuration)]
> \ MSG %"Test backup cycle%" %b%
> 
> Alternatively, I'm not sure if I need to use a SATISFY
> (maybe in conjunction with a FROM/SCANFROM).
> 
> I think the range of dates to consider/scan would be
> 
>   TrigDate - (1 + periodicity - duration)days
> 
> through
> 
>   TrigDate + (1 + periodicity - duration)days
> 
> checking if
> 
>   (TrigDate - StartDate)days mod periodicity
> 
> falls within the range of 0..(Duration - 1)
> 
> Anybody else here have tips on how to do something like this? 
> 
> Thanks!
> 
> -tim
> 
> 
> 
> 
> 
> 
> _______________________________________________
> Remind-fans mailing list
> Remind-fans at lists.skoll.ca
> https://dianne.skoll.ca/mailman/listinfo/remind-fans
> Remind is at https://dianne.skoll.ca/projects/remind/



More information about the Remind-fans mailing list