How to repeat a calendar event every x seconds in macOS Sierra

calendar

I'm trying to set up calendar events in macOS Sierra's Calendar that repeat every 2,551,440 seconds (which happens to be the synodic period of the Moon).

Ultimately, I want a calendar that provides the Moon rise and set times for my location, and it also needs to list the Lunar phase (e.g. Full Moon, New Moon, etc.). I have found plenty of examples on the Internet where people have manually created the events, but that's incredibly tedious (one event per day for years!), and it's based on different time zones (and so are of no use to me).

I have seen from the ICS specifications that the file format itself supports events that recur every x seconds. I then exported an event as an ICS file, and then edited the ICS file in TextEdit, but I must've got the code wrong, as it didn't re-import into macOS Calendar with the correct repeat interval. Instead, it imported a single event with no repetition.

Can someone please explain how to go about doing this?

I found the RRULE Generator, but that only supports hourly intervals, not seconds, and so is not precise enough for my needs.

I considered running a bash script to generate the event (which would run as a cron job every 2,551,440 seconds), but that would only give a month's notice. I'd prefer to have it set up indefinitely.

Another option may be to write a script in Python to create individual ICS event files; this would also be tedious…

I understand that this can't be done in Calendar directly; the solution will most likely be manually editing each ICS file to set up the recurrence correctly, and then importing them into Calendar… I just don't know how…

Thanks in advance for any thoughts.

Best Answer

I know this won't be the answer you were looking for.

In your question you stated:

I then exported an event as an ICS file, and then edited the ICS file in TextEdit, but I must've got the code wrong, as it didn't re-import into macOS Calendar with the correct repeat interval.

Unfortunately you probably didn't get the code wrong.

While you are correct that the ICS specification does indeed support intervals down to the second, the problem is that the default macOS Calendar app doesn't support this (at least not in terms of repeat or recurrence values). So, what you want to do is not possible with the default macOS Calendar app. In fact, the problem you have is twofold, as the Calendar app does not recognise intervals:

  1. shorter than a day
  2. not represented as whole numbers

To explain this further, the first problem above would not necessarily be an issue if the Calendar app accepted a decimal value to enough decimal points, because then you could enter an event that repeated every 29.53 days.

However, even if the app did accept a decimal value, it'd likely be limited to no more than one decimal place, which won't be precise enough when dealing with days.

Unfortunately, MS Outlook won't work for you either (it doesn't accept anything less than daily intervals and even though you can enter decimal values, it just rounds them up or down).

And Fantastical, while an excellent calendar app for macOS, is as limited as the default calendar in this regard.

Instead, what you will need to do is:

  • find a solution that registers intervals shorter than a day, or works with decimal values, or
  • download one of the existing astronomical calendars for this purpose and then manually edit the ICS file to change the time zone to suit the various Australian ones you need.

Sorry this isn't what you were looking for, but maybe the second 'download and edit' option will work for you without too much effort.

Related Question