1: \begin{abstract}
2: For a general class of nonlinear port-Hamiltonian systems we develop a high-order time discretization scheme with certain structure preservation properties.
3: The possibly infinite-dimensional system under consideration possesses a Hamiltonian function, which represents an energy in the system and is conserved or dissipated along solutions.
4: The numerical scheme is energy-consistent in the sense that the Hamiltonian of the approximate solutions at time grid points behaves accordingly.
5: This structure preservation property is achieved by specific design of a continuous Petrov--Galerkin (cPG) method in time.
6: It coincides with standard cPG methods in special cases, in which the latter are energy-consistent.
7: Examples of port-Hamiltonian ODEs and PDEs are presented to visualize the framework.
8: In numerical experiments the energy consistency is verified and the convergence behavior is investigated.
9: \end{abstract}
10: