Fix download history timestamps always showing 'Just now'
SQLite CURRENT_TIMESTAMP stores UTC but the format lacks a timezone marker. JavaScript parsed it as local time, causing future-dated timestamps and negative diffs that always fell into 'Just now'. Normalize by appending 'Z' to mark as UTC before parsing.
This commit is contained in:
parent
06defcfa3d
commit
88890f816f
1 changed files with 6 additions and 1 deletions
|
|
@ -21177,7 +21177,12 @@ function renderHistoryEntry(entry) {
|
|||
function formatHistoryTime(isoStr) {
|
||||
if (!isoStr) return '';
|
||||
try {
|
||||
const date = new Date(isoStr);
|
||||
// SQLite CURRENT_TIMESTAMP is UTC but lacks timezone marker — append Z
|
||||
let normalized = isoStr;
|
||||
if (/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}/.test(normalized) && !normalized.includes('Z') && !normalized.includes('+')) {
|
||||
normalized = normalized.replace(' ', 'T') + 'Z';
|
||||
}
|
||||
const date = new Date(normalized);
|
||||
const now = new Date();
|
||||
const diffMs = now - date;
|
||||
const diffMins = Math.floor(diffMs / 60000);
|
||||
|
|
|
|||
Loading…
Reference in a new issue