Show build time in GMT+8 with 'built N ago' in Settings About
This commit is contained in:
@@ -2161,7 +2161,18 @@ async function renderSettings() {
|
|||||||
const bt = $('aboutBuildTime');
|
const bt = $('aboutBuildTime');
|
||||||
if (bt) {
|
if (bt) {
|
||||||
const t = v.buildTime ? new Date(v.buildTime) : null;
|
const t = v.buildTime ? new Date(v.buildTime) : null;
|
||||||
bt.textContent = t && !isNaN(t) ? t.toLocaleString() : 'unknown';
|
if (t && !isNaN(t)) {
|
||||||
|
// Shown in GMT+8 regardless of device/server timezone, plus build age.
|
||||||
|
const gmt8 = new Date(t.getTime() + 8 * 3600e3).toISOString().replace('T', ' ').slice(0, 16);
|
||||||
|
const s = Math.max(0, Math.floor((Date.now() - t.getTime()) / 1000));
|
||||||
|
const ago = s < 60 ? `${s} second${s === 1 ? '' : 's'} ago`
|
||||||
|
: s < 3600 ? `${Math.floor(s / 60)} minute${Math.floor(s / 60) === 1 ? '' : 's'} ago`
|
||||||
|
: s < 86400 ? `${Math.floor(s / 3600)} hour${Math.floor(s / 3600) === 1 ? '' : 's'} ago`
|
||||||
|
: `${Math.floor(s / 86400)} day${Math.floor(s / 86400) === 1 ? '' : 's'} ago`;
|
||||||
|
bt.textContent = `${gmt8} +08 · built ${ago}`;
|
||||||
|
} else {
|
||||||
|
bt.textContent = 'unknown';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch { /* offline — leave the static version in place */ }
|
} catch { /* offline — leave the static version in place */ }
|
||||||
|
|||||||
Reference in New Issue
Block a user