diff options
author | Giampaolo Rodola <g.rodola@gmail.com> | 2020-02-13 20:32:42 -0800 |
---|---|---|
committer | Giampaolo Rodola <g.rodola@gmail.com> | 2020-02-13 20:32:42 -0800 |
commit | c67ab01eddd0cce391aeeb315d1fac8984cb2fba (patch) | |
tree | c3db2b93deb0eef01bcd6e8ce12a438fd92a7ac9 | |
parent | 8bc5a180e96445fcd9e96fa6aebf8bc698910d96 (diff) | |
download | psutil-c67ab01eddd0cce391aeeb315d1fac8984cb2fba.tar.gz |
#1693: also increase precision of users()'s login time
-rw-r--r-- | HISTORY.rst | 4 | ||||
-rw-r--r-- | psutil/_psutil_windows.c | 16 |
2 files changed, 8 insertions, 12 deletions
diff --git a/HISTORY.rst b/HISTORY.rst index 7341b6d7..52b46f7f 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -18,8 +18,8 @@ XXXX-XX-XX raising AccessDenied). - 1679_: [Windows] net_connections() and Process.connections() are 10% faster. - 1686_: [Windows] added support for PyPy on Windows. -- 1693_: [Windows] boot_time() and Process.create_time() now have the precision - of a micro second (before the precision was of a second). +- 1693_: [Windows] boot_time(), Process.create_time() and users()'s login time + now have 1 micro second precision (before the precision was of 1 second). **Bug fixes** diff --git a/psutil/_psutil_windows.c b/psutil/_psutil_windows.c index 109ed6c5..82fa518e 100644 --- a/psutil/_psutil_windows.c +++ b/psutil/_psutil_windows.c @@ -1195,7 +1195,6 @@ psutil_users(PyObject *self, PyObject *args) { DWORD bytes; PWTS_CLIENT_ADDRESS address; char address_str[50]; - long long unix_time; WINSTATION_INFO station_info; ULONG returnLen; PyObject *py_tuple = NULL; @@ -1271,18 +1270,15 @@ psutil_users(PyObject *self, PyObject *args) { goto error; } - unix_time = ((LONGLONG)station_info.ConnectTime.dwHighDateTime) << 32; - unix_time += \ - station_info.ConnectTime.dwLowDateTime - 116444736000000000LL; - unix_time /= 10000000; - py_username = PyUnicode_FromWideChar(buffer_user, wcslen(buffer_user)); if (py_username == NULL) goto error; - py_tuple = Py_BuildValue("OOd", - py_username, - py_address, - (double)unix_time); + py_tuple = Py_BuildValue( + "OOd", + py_username, + py_address, + psutil_FiletimeToUnixTime(station_info.ConnectTime) + ); if (!py_tuple) goto error; if (PyList_Append(py_retlist, py_tuple)) |