time() fix intl issue

This commit is contained in:
Sebastian Hildebrandt 2025-06-27 23:24:28 +02:00
parent 82beee3dd4
commit b91d260b23
3 changed files with 11 additions and 5 deletions

View File

@ -30,8 +30,8 @@
## The Systeminformation Project
This is amazing. Started as a small project just for myself, it now has > 17,000
lines of code, > 650 versions published, up to 8 mio downloads per month, > 350
This is amazing. Started as a small project just for myself, it now has > 18,000
lines of code, > 700 versions published, up to 9 mio downloads per month, > 380
mio downloads overall. Top 10 NPM ranking for backend packages. Thank you to all
who contributed to this project!

View File

@ -204,7 +204,7 @@
</div>
<div class="row number-section">
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
<div class="numbers">18,504</div>
<div class="numbers">18,542</div>
<div class="title">Lines of code</div>
</div>
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
@ -212,7 +212,7 @@
<div class="title">Downloads last month</div>
</div>
<div class="col-xl-4 col-lg-4 col-md-4 col-12">
<div class="numbers">865</div>
<div class="numbers">867</div>
<div class="title">Dependents</div>
</div>
</div>

View File

@ -34,11 +34,17 @@ const _sunos = (_platform === 'sunos');
function time() {
let t = new Date().toString().split(' ');
let timezoneName = '';
try {
timezoneName = Intl.DateTimeFormat().resolvedOptions().timeZone;
} catch {
timezoneName = (t.length >= 7) ? t.slice(6).join(' ').replace(/\(/g, '').replace(/\)/g, '') : '';
}
const result = {
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, '') : ''
timezoneName
};
if (_darwin || _linux) {
try {