Time integrators based on approximate discontinuous hamiltonians