How is average time on page set - without heartbeat

Hi, I was wondering, how does Piwik calculate time on page. Are single page views also tracked, like enter page and leave after 2 seconds, resulting in 2 seconds on page? Or is Piwik also returning 0 or not putting the time in calculation when the user exits the website?
I know you can use the heartbeat ping, but how is time measured by default?

How does the leaveContent event interact with the time measure? If not already happening, is it possible to tell Piwik to set the timer to end at this event?

Couldnt find a clear answear by now. Thanks

Hi Martin,

Time on page always is calculated as a time between first and the last event. If the first event is also the last event the difference is 0. It doesn’t matter whether or not pings are used, the rule is still the same