There's been a long standing bug in ical2rem.pl - older recurring calendar
entries were not detected by the script so the entries wouldn't be output
to the remind file. I handled recurring entries and made sure only one
would appear by manipulating the lead time, but the perl ICal parser wasn't
handling older calendar entries.

I discovered a python module that does exactly what I need. It reads and
calculates all the RRULE entries, and can output calendar entries that
occur within a specified time frame. I wrote the simple
cal_upcoming_events.py script to read in the iCalendar file and output a
simplified file that has all the calculated entries. The UID isn't changed
so my code that manipulates the lead time to make sure only one instance
shows up in the remind output is still good. As a bonus, the python code
that trims the iCalendar to the required time frame is MUCH faster than the
20-year-old ical2rem.pl.

I call the new script on the original iCal file and pass the output to
ical2rem.pl:

> bin/cal_upcoming_events.py -i calendars/full/justin.ics -o - -b 0 -a 30 | 
> ical2rem.pl --lead-time 30 | remind -q -

Reminders for Thursday, 30th January, 2025 (today):

Calendar Events:
tomorrow at 8:00am Gym
tomorrow at 8:15pm Check in
on Saturday, 1 February, 2025 at 10:00am Meeting
on Sunday, 2 February, 2025 at 8:00pm Family call
on Monday, 3 February, 2025 at 7:15pm Adult Orchestra Rehearsal
on Tuesday, 4 February, 2025 at 7:30pm BOPO
on Thursday, 20 February, 2025 at 9:00am In Office AM
on Thursday, 20 February, 2025 at 11:10am Dental Appointment at
University Heights Dental at University Heights Dental 14141 Cedar Rd
South Euclid OH 44121
on Thursday, 20 February, 2025 at 12:20pm Haircut

The recurring Gym and Family Call events weren't showing up because they
were created more than a year ago.  The Gym is every Mon, Wed Fri so the
events after tomorrow have a lead time of +1(or +2) from my code, so only
one shows up.  When I run it on Saturday, the Monday event will show up:

bin/cal_upcoming_events.py -i calendars/full/justin.ics -o - -b 0 -a 30 |
ical2rem.pl --lead-time 30 | remind -q - 2025-02-01
Reminders for Saturday, 1st February, 2025:

Calendar Events:
today at 10:00am Meeting
today at 8:15pm Check in
tomorrow at 8:00pm Family call
on Monday, 3 February, 2025 at 8:00am Gym

I've updated a new branch of ical2rem.pl at
https://github.com/jbalcorn/ical2rem/tree/python - if anyone is interested
in taking a look at the new script to see if there's any issues please do.

I was thinking about rewriting ical2rem.pl in python - obviously that
already exists thanks to Jochen, but hey, I need some practice in python :-)

Here's the docstring from the new script:

"""Ingests a icalendar and outputs all simplified calendar
    that includes only events that occur within a span of time

Uses the module recurring_ical_events to calculate any older
    recurring events that have occurrences within the defined span of time.

Args:
    infile: The file to read

    outfile: the file to write

    before: number of days before today to start the span

    after: number of days after today to start the span


"""

-- 
Justin B. Alcorn
The views expressed are not necessarily my own, much less anyone else's
PGP Fingerprint CCEB F776 C3FD 1050 C8DB  532E B8B9 BED7 7764 406C
_______________________________________________
Remind-fans mailing list
[email protected]
https://dianne.skoll.ca/mailman/listinfo/remind-fans
Remind is at https://dianne.skoll.ca/projects/remind/

Reply via email to