Fix off-by-one errors in some date functions