There are a number of ways to gather presence information. There's a good example that comes with the CAXL SDK called presencequickcontactsexample.html. Here's a snippet from that example, which handles presence and updates to the presence status. It binds the "entityCreated" event, which you can use to calculate the start time of a presence status. It binds the "primaryPresenceChanged" event to a function, which is called when the presence changes for a subscribed contact (you have to subscribe first).
What you'd have to do in order to poll the presence is to note the presence when "entityCreated" is triggered, and save that time. You only do this once, when you first subscribe to that contact.
Then when you want to poll the presence use contact.getPrimaryPresence(); for that subscribed contact, and calculate how long it has remained at that presence. When the presence changes, it will trigger the "primaryPresenceChanged" event, and you reset the time.
Note that the example is for quick contacts (contacts you define on the fly, not from your roster), but the principle is the same, and you can apply it to roster contacts, too.
Does that answer your questions?
* Here we bind the 'entityCreated' event on the EntitySet.
* This event is triggered when subscribing to a JID(s).
* The event is passed the jabberwerx.Entity that was created
* and is retrieved from the event data.
* The 'primaryPresenceChanged' event is bound on
* the entity to track any changes in presence. This event is
* triggered when the presence of a enitiy changes and is passed
* a jabberwerx.Presence object if connected, null if the