[Remind-Fans] Avoid type errors when using trigdatetime in msgprefix

Tim Chase remind at tim.thechases.com
Tue Mar 31 17:49:15 EDT 2020


On 2020-03-31 17:34, Juan F. Meleiro wrote:
> It adds three spaces of indentation, the middle of which is
> substituted by '*' or '>' if the event is happening *now* or later
> today. So it may show something like:
> 
>    Wednesday 2020-04-01
> 
>       12:00 Lunch
>     * 16:00 That class you should be attending
>     > 18:00 That thing you'll do later  
> 
> The problem is that doing that involves calling the function
> trigdatetime() for every reminder, and making a comparison to a
> DATETIME. That causes an error if the reminders does not have an
> AT-part, and so the whole functions evaluates to nothing (I
> should've read the man-page with more attention).

You might be able to abuse the fact that remind zero-pads times when
converting them to strings, meaning you can compare their
string-versions and you should get the same results

  FSET msgprefix(x) " " + \
    iif(trigtime() == 0, " ", \
    iif(( \
      (trigtime() + "") \
      >= \
      (realnow() + "") \
    ), \
    ">", \
    "*")) + " "

  REM [today()] MSG No AT%
  REM [today()] AT 1:00 MSG Has early AT%
  REM [today()] AT [realnow() - 5] MSG Has recent AT%
  REM [today()] AT [realnow()] MSG Has current AT%
  REM [today()] AT 23:00 MSG Has late AT%

If you want to bias it by a couple minutes so that something that
started 10 minutes ago is considered "still now", you can do that too:

  FSET msgprefix(x) " " + \
    iif(trigtime() == 0, " ", \
    iif(( \
      (trigtime() + "") \
      >= \
      ((realnow() - 10) + "") \
    ), \
    ">", \
    "*")) + " "

changing that "realnow()" to "realnow() - 10" (or whatever bias you'd
consider an event still being "now")

I might have fouled up your logic, but the idea should hold for
however you intend to translate it.

-tim









More information about the Remind-fans mailing list