Refactor and document the calendars helper

I stumbled across the calendars helper and couldn't look away...