Category Archives: Ical RFC5545 / 2445

Notes on working with the icalendar spec:http://www.ietf.org/rfc/rfc5545.txt
(RFC2445 spec is obsolete)
More readable format here using old spec: http://www.kanzaki.com/docs/ical/

Paydays, Last working days and why BYSETPOS is useful

Have you ever wondered how to represent important recurring events like a ‘payday’ or a last business day?

If your calendar application allows you to enter the “set position” along with other recurring rules, then you’ll need to know about BYSETPOS.

In a ical recurring event, the BYSETPOS is a comma separated list of numbers (1 to 366 or -1 to -366). It MUST be used with another ‘BY’ rule such as BYDAY, BYMONTH etc.

It “chooses” the ‘nth’ occurrence within a set of dates determined by the preceding rules.

For example, in a WEEKLY rule, the interval would be one week. (Remember to consider what the “start of the week” is for the set you are using). A set of recurrence instances starts at the beginning of the interval defined by the FREQ rule part.

Formal definition

For the formal definition see http://www.ietf.org/rfc/rfc5545.txt

Examples

The last work day of the month

FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=-1

‘PAY DAY’ – the last week day in the month!

RRULE:FREQ=MONTHLY;BYDAY=-1MO,-1TU,-1WE,-1TH,-1FR;BYSETPOS=-1

The 30th of every month; or the last day of the month if the 30th doesn’t exist

FREQ=MONTHLY;BYMONTHDAY=28,29,30;BYSETPOS=-1

For Developers

According to the very useful table of recurring rule precedence of page 43, the BYSETPOS is applied last within an iteration of the ‘FREQ’ on the set of dates generated by the rule.  If you programmaticaly follow the table logic, you should be able to avoid problems implementing BYSETPOS.

TZID’s with quotes around them

Some ics files (eg: a zimbra file)  I have encountered have the TZID enclosed in quotes.

DTSTART;TZID=”America/New_York”:20080908T130000

The usual use (google calendar etc) is:

DTSTART;TZID=America/New_York:20080908T130000

The spec examples do not show quotes and the quotes in the terminology definition are not I think meant to be included in the data.  However this is relatively easy to deal with, so the next version of the plugin > 2.9.4 will cope with these.

Please note that the plugin currently ignores the VTIMEZONE in the ics file and uses the php database timezone.

The plugin will also not cope with the following yet (I have not yet encountered an ics file with it’s own timezone identifiers yet!):

fictitious globally unique time zone identifier example:

TZID:/US-New_York-New_York

Ical Calendar to html options

Some considerations in choosing a plugin or script to import one or more shared calendar ical feeds:

  • Completeness and/or robustness of ical implementation? vs type of dates expected by your application. A complete implementation may of necessity be more complex than a simple one. If your dates are simple, may be a simple solution is the answer. Or do you need to allow for all the variations of recurring specifications?
  • Does it cater for all the fields you need? (attendees etc….)
  • Box Calendar or List of Events (Agenda Style)
  • Verbose or concise text (eg: Mo, Tu vs Monday, Tuesday)
  • Explanatory Text options to change?
  • Hardcoded english? or are there language translation options?
  • Possibilities for css styling – does the html code produced allow adequate styling opportunities?
  • Caching? If you have a high volume site, or you want the calendar or agenda in your sidebar, then you need to cache the ics file to avoid placing too much of a load on the server that is hosting the ics file (and slowing down your site)
  • Can it handle or combine multiple calendars?
  • Will it repeat the recurring events per day? or does it note the fact that they repeat on the first day or the current day?

Resources

WordPress Ical (ics file) import options:

These are ‘old’ – please see http://webdesign.anmari.com/95/comparison-of-event-calendar-plug-ins/

 

 

  • http://wordpress.org/extend/plugins/wordpress-ics-importer/ This one looks good, not a full implementation of the code, but the code that is there is well structured, allowing for additional implementation in a clean fashion. Provides a cache. No language translation and alternative css and html options are possible, but not that obvious or easy until you dig into the code. One calendar at a time.