Added a guard against null dates.