unify & templatize timeval conversion