Defensive code around date processing