Mimsy Were the Borogoves

Hacks: Articles about programming in Python, Perl, PHP, and whatever else I happen to feel like hacking at.

icalBuddy and eventsFrom/to

Jerry Stratton, August 19, 2015

I use icalBuddy extensively along with GeekTool to display events on my desktop. I have the fairly standard sort of “here are your upcoming events”:

  • icalBuddy --excludeCals Television --excludeEventProps url --dateFormat "%A" --includeOnlyEventsFromNowOn eventsToday+4

This shows everything from the rest of today through four days from now. But you’ll notice it excludes one calendar: I really don’t need to see a list of the television shows I sometimes watch. They’re not that important to me.

Up until about a week ago, I showed only television shows for today:

  • icalBuddy --includeCals Television --excludeEventProps url --dateFormat "%A" --includeOnlyEventsFromNowOn eventsToday

And it worked fine, until the local old movies television station had William Castle’s classic 13 Ghosts on at 1:20 AM a few weeks ago. I missed it, because 1:20 AM isn’t today, it’s tomorrow. But by the time I look at it tomorrow morning, 1:20 AM is long gone.

I initially changed it to “eventsToday+1”, but that clutters up my desktop with events for tomorrow night, which I don’t need to know about now. I don’t plan my life around television shows, I just want to know if there’s something interesting right now. What I really want is for today’s list to include until tomorrow morning. The icalBuddy man page indicates that it’s possible to specify a range that includes an hour on a relative end date, but the documentation is currently wrong. For the option “eventsFrom:START to:END”, it says:

Print events occurring between the two specified dates. The dates (START and END) may be specified in a natural language form (such as "tomorrow at noon" or "june 10 at 6 pm") or as relative dates (such as "today+3" or "yesterday-2") but the safest format is "YYYY-MM-DD HH:MM:SS +HHMM"

Specifying tomorrow at noon, or tomorrow at 8 am, or tomorrow at anything just shows everything from tomorrow. A quick use of --debug confirmed it: icalBuddy interprets “tomorrow at” anything to be “[tomorrow] at 11:59:59 PM Central Daylight Time”.

I verified, however, that the to: option can accept partial days, by using the actual date (August 20 at 7 pm, for example), so I messed around until I found a format that works. Rather than “tomorrow at time”, use “time at tomorrow”:

  • icalBuddy --includeCals Television --excludeEventProps url -f --dateFormat "%A" --includeOnlyEventsFromNowOn eventsFrom:today to:"noon tomorrow"
  • icalBuddy --includeCals Television --excludeEventProps url -f --dateFormat "%A" --includeOnlyEventsFromNowOn eventsFrom:today to:"9 am tomorrow"

The first is interpreted as noon tomorrow, and the second as 9 am tomorrow, only showing things in the morning from tomorrow instead of all day.

  1. <- Automator filenames
  2. Pythonista circle ->