Move wrapTime to a free function.