Change dateFormat to a more general formatter function