Fix some errors calculating dates.