clean some date handling code