calendarProvider: simplify task state switching code