Fix #2272: TypeError occurs by cast to Date from undefined