Make time format customizable

Replace the hardcoded time format strings with a configurable time format. I stripped trailing whitespaces on the edited files as well.