users() improved date parsing (macOS)
This commit is contained in:
parent
8d1e037342
commit
0cc50fcac5
@ -90,6 +90,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
|
||||
|
||||
| Version | Date | Comment |
|
||||
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
|
||||
| 5.24.5 | 2025-01-02 | `users()` improved date parsing (macOS) |
|
||||
| 5.24.4 | 2025-01-02 | `__proto__` added prototypes |
|
||||
| 5.24.3 | 2025-01-01 | `__proto__` deno compatibility |
|
||||
| 5.24.2 | 2025-01-01 | `versions()` fixed node version |
|
||||
|
||||
@ -57,6 +57,11 @@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<th scope="row">5.24.5</th>
|
||||
<td>2025-01-02</td>
|
||||
<td><span class="code">users()</span> improved date parsing (macOS)</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<th scope="row">5.24.4</th>
|
||||
<td>2025-01-02</td>
|
||||
|
||||
@ -170,7 +170,7 @@
|
||||
<img class="logo" src="assets/logo.png" alt="logo">
|
||||
<div class="title">systeminformation</div>
|
||||
<div class="subtitle"><span id="typed"></span> </div>
|
||||
3<div class="version">New Version: <span id="version">5.24.4</span></div>
|
||||
3<div class="version">New Version: <span id="version">5.24.5</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">
|
||||
|
||||
14
lib/users.js
14
lib/users.js
@ -105,10 +105,18 @@ function parseUsersDarwin(lines) {
|
||||
|
||||
// who part
|
||||
if (is_whopart) {
|
||||
let dt = ('' + new Date().getFullYear()) + '-' + ('0' + ('JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'.indexOf(l[2].toUpperCase()) / 3 + 1)).slice(-2) + '-' + ('0' + l[3]).slice(-2);
|
||||
try {
|
||||
if (new Date(dt) > new Date) {
|
||||
dt = ('' + (new Date().getFullYear() - 1)) + '-' + ('0' + ('JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'.indexOf(l[2].toUpperCase()) / 3 + 1)).slice(-2) + '-' + ('0' + l[3]).slice(-2);
|
||||
}
|
||||
} catch {
|
||||
util.noop();
|
||||
}
|
||||
result_who.push({
|
||||
user: l[0],
|
||||
tty: l[1],
|
||||
date: ('' + new Date().getFullYear()) + '-' + ('0' + ('JANFEBMARAPRMAYJUNJULAUGSEPOCTNOVDEC'.indexOf(l[2].toUpperCase()) / 3 + 1)).slice(-2) + '-' + ('0' + l[3]).slice(-2),
|
||||
date: dt,
|
||||
time: l[4],
|
||||
});
|
||||
} else {
|
||||
@ -146,7 +154,7 @@ function users(callback) {
|
||||
|
||||
// linux
|
||||
if (_linux) {
|
||||
exec('who --ips; echo "---"; w | tail -n +2', function (error, stdout) {
|
||||
exec('export LC_ALL=C; who --ips; echo "---"; w; unset LC_ALL | tail -n +2', function (error, stdout) {
|
||||
if (!error) {
|
||||
// lines / split
|
||||
let lines = stdout.toString().split('\n');
|
||||
@ -195,7 +203,7 @@ function users(callback) {
|
||||
}
|
||||
|
||||
if (_darwin) {
|
||||
exec('who; echo "---"; w -ih', function (error, stdout) {
|
||||
exec('export LC_ALL=C; who; echo "---"; w -ih; unset LC_ALL', function (error, stdout) {
|
||||
if (!error) {
|
||||
// lines / split
|
||||
let lines = stdout.toString().split('\n');
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user