users() fix windows (time), added @ts-check

This commit is contained in:
Sebastian Hildebrandt 2019-02-23 15:02:15 +01:00
parent 2794d4342b
commit d1b05fa691
18 changed files with 36 additions and 4 deletions

View File

@ -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 |

View File

@ -80,6 +80,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">4.0.11</th>
<td>2019-02-23</td>
<td><span class="code">users()</span> fix windows (time), added @ts-check</td>
</tr>
<tr>
<th scope="row">4.0.10</th>
<td>2019-02-10</td>

View File

@ -170,7 +170,7 @@
<img class="logo" src="assets/logo.png">
<div class="title">systeminformation</div>
<div class="subtitle"><span id="typed"></span></div>
<div class="version">Current Version: <span id="version">4.0.10</span></div>
<div class="version">Current Version: <span id="version">4.0.11</span></div>
<button class="btn btn-light" onclick="location.href='https://github.com/sebhildebrandt/systeminformation'">View on Github <i class=" fab fa-github"></i></button>
</div>
<div class="down">
@ -193,7 +193,7 @@
</div>
<div class="row number-section">
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
<div class="numbers">8,137</div>
<div class="numbers">8,112</div>
<div class="title">Lines of code</div>
</div>
<div class="col-xl-4 col-lg-4 col-md-4 col-12">

View File

@ -1,4 +1,5 @@
'use strict';
// @ts-check;
// ==================================================================================
// battery.js
// ----------------------------------------------------------------------------------

View File

@ -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);

View File

@ -1,4 +1,5 @@
'use strict';
// @ts-check
// ==================================================================================
// docker.js
// ----------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
'use strict';
// @ts-check
// ==================================================================================
// dockerSockets.js
// ----------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
'use strict';
// @ts-check
// ==================================================================================
// filesystem.js
// ----------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
'use strict';
// @ts-check
// ==================================================================================
// graphics.js
// ----------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
'use strict';
// @ts-check
// ==================================================================================
// index.js
// ----------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
'use strict';
// @ts-check
// ==================================================================================
// internet.js
// ----------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
'use strict';
// @ts-check
// ==================================================================================
// memory.js
// ----------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
'use strict';
// @ts-check
// ==================================================================================
// network.js
// ----------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
'use strict';
// @ts-check
// ==================================================================================
// osinfo.js
// ----------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
'use strict';
// @ts-check
// ==================================================================================
// processes.js
// ----------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
'use strict';
// @ts-check
// ==================================================================================
// system.js
// ----------------------------------------------------------------------------------

View File

@ -1,4 +1,5 @@
'use strict';
// @ts-check
// ==================================================================================
// users.js
// ----------------------------------------------------------------------------------

View File

@ -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;
}