Fix bug in computing day of next event