Improve timeformat code.