edited
got rid of useless code
intelligently setting date string format based on time scale