Get user’s login duration time without time of locked screen

I’d like to get information about “utilization time” of users on linux sytems for specific days. This means the time, an user has an unlocked screen. In contrast the command ac displays the whole time, a user is logged in, including the time with locked screen or standby.

As far as I knows, the idle time displayed by who command differs from the time with unlocked screen. So that’s apparently not the solution.

The open source progam Timekpr displays the wanted information, but only for the current week. May be it is possible to extract the code for that calculation. However, my programming skills are too bad for that.