From d1b05fa6913c87de72b2c15fe667102ea17dd8b5 Mon Sep 17 00:00:00 2001 From: Sebastian Hildebrandt Date: Sat, 23 Feb 2019 15:02:15 +0100 Subject: [PATCH] users() fix windows (time), added @ts-check --- CHANGELOG.md | 1 + docs/history.html | 5 +++++ docs/index.html | 4 ++-- lib/battery.js | 1 + lib/cpu.js | 3 ++- lib/docker.js | 1 + lib/dockerSocket.js | 1 + lib/filesystem.js | 1 + lib/graphics.js | 1 + lib/index.js | 1 + lib/internet.js | 1 + lib/memory.js | 1 + lib/network.js | 1 + lib/osinfo.js | 1 + lib/processes.js | 1 + lib/system.js | 1 + lib/users.js | 1 + lib/util.js | 14 +++++++++++++- 18 files changed, 36 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b50f5e1..5a99f78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ For major (breaking) changes - version 3 and 2 see end of page. | Version | Date | Comment | | -------------- | -------------- | -------- | +| 4.0.11 | 2019-02-23 | `users()` fix windows (time), added @ts-check | | 4.0.10 | 2019-02-10 | `networkInterfaceDefault()` fix windows | | 4.0.9 | 2019-02-08 | `cpu()` fix, code cleanup | | 4.0.8 | 2019-02-05 | `inetLatency()` Windows fix parse chinese output | diff --git a/docs/history.html b/docs/history.html index db41646..b89e39e 100644 --- a/docs/history.html +++ b/docs/history.html @@ -80,6 +80,11 @@ + + 4.0.11 + 2019-02-23 + users() fix windows (time), added @ts-check + 4.0.10 2019-02-10 diff --git a/docs/index.html b/docs/index.html index 34308f8..1fcea6f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -170,7 +170,7 @@
systeminformation
-
Current Version: 4.0.10
+
Current Version: 4.0.11
@@ -193,7 +193,7 @@
-
8,137
+
8,112
Lines of code
diff --git a/lib/battery.js b/lib/battery.js index 758bda4..21951d0 100644 --- a/lib/battery.js +++ b/lib/battery.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check; // ================================================================================== // battery.js // ---------------------------------------------------------------------------------- diff --git a/lib/cpu.js b/lib/cpu.js index 6435beb..eb405b6 100644 --- a/lib/cpu.js +++ b/lib/cpu.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // cpu.js // ---------------------------------------------------------------------------------- @@ -582,7 +583,7 @@ function cpuCurrentspeed(callback) { max: currCpuSpeed, avg: currCpuSpeed, cores: [] - } + }; } if (callback) { callback(result); } resolve(result); diff --git a/lib/docker.js b/lib/docker.js index 871e16d..4ef0e79 100644 --- a/lib/docker.js +++ b/lib/docker.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // docker.js // ---------------------------------------------------------------------------------- diff --git a/lib/dockerSocket.js b/lib/dockerSocket.js index 4718d44..0c6bfb2 100644 --- a/lib/dockerSocket.js +++ b/lib/dockerSocket.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // dockerSockets.js // ---------------------------------------------------------------------------------- diff --git a/lib/filesystem.js b/lib/filesystem.js index 6fb7eee..9474f8c 100644 --- a/lib/filesystem.js +++ b/lib/filesystem.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // filesystem.js // ---------------------------------------------------------------------------------- diff --git a/lib/graphics.js b/lib/graphics.js index ee41959..2ca3946 100644 --- a/lib/graphics.js +++ b/lib/graphics.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // graphics.js // ---------------------------------------------------------------------------------- diff --git a/lib/index.js b/lib/index.js index 8cf5246..fc75554 100644 --- a/lib/index.js +++ b/lib/index.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // index.js // ---------------------------------------------------------------------------------- diff --git a/lib/internet.js b/lib/internet.js index 755a788..676e4e2 100644 --- a/lib/internet.js +++ b/lib/internet.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // internet.js // ---------------------------------------------------------------------------------- diff --git a/lib/memory.js b/lib/memory.js index d34ee1f..6c1aed9 100644 --- a/lib/memory.js +++ b/lib/memory.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // memory.js // ---------------------------------------------------------------------------------- diff --git a/lib/network.js b/lib/network.js index 1fdd8d1..7a23be3 100644 --- a/lib/network.js +++ b/lib/network.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // network.js // ---------------------------------------------------------------------------------- diff --git a/lib/osinfo.js b/lib/osinfo.js index 38b6b6b..228e97a 100644 --- a/lib/osinfo.js +++ b/lib/osinfo.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // osinfo.js // ---------------------------------------------------------------------------------- diff --git a/lib/processes.js b/lib/processes.js index 01817a3..abb8532 100644 --- a/lib/processes.js +++ b/lib/processes.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // processes.js // ---------------------------------------------------------------------------------- diff --git a/lib/system.js b/lib/system.js index a9220ac..5ade7f9 100644 --- a/lib/system.js +++ b/lib/system.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // system.js // ---------------------------------------------------------------------------------- diff --git a/lib/users.js b/lib/users.js index 9593c8f..bdabd4e 100644 --- a/lib/users.js +++ b/lib/users.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // users.js // ---------------------------------------------------------------------------------- diff --git a/lib/util.js b/lib/util.js index cc1031e..815d4a2 100644 --- a/lib/util.js +++ b/lib/util.js @@ -1,4 +1,5 @@ 'use strict'; +// @ts-check // ================================================================================== // utils.js // ---------------------------------------------------------------------------------- @@ -107,6 +108,16 @@ function decodeEscapeSequence(str, base) { }); } +function parseTime(t) { + t = t.toUpperCase(); + const parts = t.split(':'); + let isPM = (parts[1] && parts[1].indexOf('PM') > -1); + let hour = parseInt(parts[0], 10); + const min = parseInt(parts[1], 10); + hour = isPM && hour < 12 ? hour + 12 : hour; + return ('0' + hour).substr(-2) + ':' + ('0' + min).substr(-2); +} + function parseDateTime(dt) { const result = { date: '', @@ -137,7 +148,8 @@ function parseDateTime(dt) { } } if (parts[1]) { - result.time = parts[1]; + let time = parts[1] + (parts[2] ? parts[2] : ''); + result.time = parseTime(time); } return result; }