consolidate time/date handling code