calendarProvider: avoid infinite loop in probably-impossible-to-happen situation.
Code style changes.