clean up datetime formatting code