There are a few plugins that Adobe provides, I haven't used either of these, but I have seen others who have:
getTimeToComplete
https://experienceleague.adobe.com/docs/analytics/implementation/vars/plugins/gettimetocomplete.html?lang=en
This is based on firing a start and stop command
getTimeBetweenEvents
https://experienceleague.adobe.com/docs/analytics/implementation/vars/plugins/gettimebetweenevents.html?lang=en
This is based on looking at events that you are already firing and calculating the time between them.
Now, in your case, you are trying to get all time spend for User X (across visits) from entering the site until they add to the cart....
As far as I am aware, both of these plugins need to be within the same visit....
Given that Adobe's time spend is based solely on timestamps, I don't think that you can do this from a tagging solution... Adobe doesn't take into account "time spend off the site, or between visits"... if you were to look at those timestamps, all the time the user wasn't on your site would be calculated as part of the time spent....
I think in this case, you would need to take this out of Adobe, and use external tools... You could use a combination of time spent by the visitor (up until the visit with a cart add) and using one of the above functions to track the time within a visit from start of visit until cart add... but you would also need to identify the first page of the visit to start the tracking, and then to trigger the stop on the cart.....
Or you could just take this fully out using Raw Data feeds (after processing the data), then stitching user data based on first visit timestamp until the last timestamp in the visit, and calculate everything up until the "add to cart" action....