Factor out formatting of timestamps