diff --git a/src/js/backend.js b/src/js/backend.js index d88726e..2918805 100644 --- a/src/js/backend.js +++ b/src/js/backend.js @@ -19,11 +19,11 @@ document.addEventListener('DOMContentLoaded', function () { }); // Function to convert seconds to human readable duration -function formatDuration(seconds) { +function formatDuration(seconds, isMilliseconds = false) { if (!seconds || isNaN(seconds)) return seconds; // Convert to number in case it's a string - const totalSeconds = parseFloat(seconds); + const totalSeconds = isMilliseconds ? parseFloat(seconds) / 1000 : parseFloat(seconds); // Calculate days, hours, minutes, seconds const days = Math.floor(totalSeconds / 86400); @@ -163,7 +163,9 @@ function processTimestamps( typeof value === 'number' && document.getElementById('replaceKeysOption').checked ) { - result[key] = formatDuration(value); + // Check if the key is 'duration' to know if it's in milliseconds + const isMilliseconds = key === 'duration'; + result[key] = formatDuration(value, isMilliseconds); } else if (typeof value === 'object' && value !== null) { result[key] = processTimestamps( value,