Improve date selection logic for calendar.