[Remind-Fans] Issues with changing baseyr()? And partial FROM specification?
Tim Chase
remind at tim.thechases.com
Fri Sep 8 17:44:04 EDT 2023
I've got some slow & absolutely atrocious hacks[1] for dealing with
years < baseyr() in my reminders. I use them for birthdays to store
the year in one place[2], allowing me to elsewhere extract the year
for calculating the person's age,a couple's anniversary, or other
such deltas.
In an ideal world, baseyr() would accommodate pretty much everybody
I know, allowing for dates back to the early 1900s (I think my late
grandfather was the oldest at 1918).
As an added hope, I'd love to be able to specify a partial date
(the year here) in the FROM and have it take the rest of it from
the base date specification, something like
REM Jul 13 FROM 1976 MSG Joe's birthday [age()]
REM Aug 23 FROM 1972 MSG Mom & Dad [age()]
would get interpreted as
REM Jul 13 FROM Jul 13 1976 MSG Joe's birthday [age()]
where age() is as simple as
FSET age() ord($Ty - year(trigfrom()))
Is there any issue with rebuilding this with a much earlier year
like 1900? Things that might break that I should watch out for?
And any thoughts on the FROM taking omitted parts from the main
reminder?
-tkc
[1]
Vile atrocious horrible sins follow. Consider yourself warned.
Try not to cry too much when you read this. But it works for
what I wanted it to do.
SET YRTAG "_from_year_"
# if the year is < baseyr(),
# store it in a tag with that year as part of it
# like "TAG _from_year_1943",
# otherwise create a FROM,
# taking the month/day from the event date
# like "FROM Jun 12 2014"
FSET frm(y) iif(y<baseyr(), \
"TAG " + YRTAG + y, \
"FROM " + date(iif(y<baseyr(), baseyr(), y), $Um, $Ud)\
)
# extract the year back from our hack
FSET yr() iif(trigfrom() == -1, \
coerce("INT", substr( \
trigtags(), \
index(trigtags(), YRTAG) + \
strlen(YRTAG), \
index(trigtags(), YRTAG) + \
strlen(YRTAG) + 3 \
) \
), \
year(iif(trigfrom() == -1, $T, trigfrom())) \
)
FSET o() ord($Ty - yr())
FSET ago() "(" + ($Ty - yr()) + " ago)"
FSET born() "(" + ($Ty - yr()) + "yo)"
FSET anniv() "(" + ord($Ty - yr()) + ")"
FSET died() "(died " + ($Ty - yr()) + "y ago)"
letting me do things like
REM Jun 12 [frm(1936)] MSG %"Grandma%" [born()]
REM Aug 23 [frm(1972)] MSG Mom & Dad [anniv()]
If you haven't guessed, this is s...l...o...w. It's not bad on my
higher-powered daily driver, but on a RPi or my little sliver of
VPS hosting or older hardware, it's a good several seconds to compile
and display my agenda.
[2] Okay, it's *entered* in one place, but depending on the year,
an expression expands it either into the FROM or the hack with a
TAG
More information about the Remind-fans
mailing list