time() changed retrieval of timezones (linux, macOS)

This commit is contained in:
Sebastian Hildebrandt 2024-12-12 08:02:18 +01:00
parent 97c79625ad
commit 5993adeb79
4 changed files with 26 additions and 6 deletions

View File

@ -90,6 +90,7 @@ For major (breaking) changes - **version 4, 3 and 2** - see end of page.
| Version | Date | Comment |
| ------- | ---------- | --------------------------------------------------------------------------------------------------- |
| 5.23.10 | 2024-12-12 | `time()` changed retrieval of timezones (linux, macOS) |
| 5.23.9 | 2024-12-11 | `typings` added definitions with overload |
| 5.23.8 | 2024-12-10 | `system()` added Raspberry 500 detection |
| 5.23.7 | 2024-12-09 | `networkInterfaces()` sanitizing SSID names (windows) |

View File

@ -57,6 +57,11 @@
</tr>
</thead>
<tbody>
<tr>
<th scope="row">5.23.10</th>
<td>2024-12-12</td>
<td><span class="code">time()</span> changes retrieval of timezones (linux, macOS)</td>
</tr>
<tr>
<th scope="row">5.23.9</th>
<td>2024-12-11</td>

View File

@ -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>&nbsp;</div>
<div class="version">New Version: <span id="version">5.23.9</span></div>
<div class="version">New Version: <span id="version">5.23.10</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">

View File

@ -34,12 +34,26 @@ const _sunos = (_platform === 'sunos');
function time() {
let t = new Date().toString().split(' ');
if (_darwin || _linux) {
const stdout = execSync('date +%Z && date +%z && ls -l /etc/localtime 2>/dev/null', util.execOptsLinux);
const lines = stdout.toString().split(os.EOL);
if (lines.length > 3 && !lines[0]) {
lines.shift();
}
return {
current: Date.now(),
uptime: os.uptime(),
timezone: lines[0] && lines[1] ? lines[0] + lines[1] : '',
timezoneName: lines[2] && lines[2].indexOf('/zoneinfo/') > 0 ? (lines[2].split('/zoneinfo/')[1] || '') : ''
};
} else {
return {
current: Date.now(),
uptime: os.uptime(),
timezone: (t.length >= 7) ? t[5] : '',
timezoneName: Intl ? Intl.DateTimeFormat().resolvedOptions().timeZone : (t.length >= 7) ? t.slice(6).join(' ').replace(/\(/g, '').replace(/\)/g, '') : ''
};
};
}
exports.time = time;