Split time_format off into a new function to keep things neat