Logic for calendar