Merge pull request #1 from Pablo2048/development

Local time in timestamp
This commit is contained in:
2024-10-11 15:06:36 +02:00
committed by GitHub
2 changed files with 7 additions and 2 deletions

View File

@@ -1,2 +1,3 @@
# trace.js
Javascript logging library
Javascript logging library better than use ordinary `console.log(...)` logging, partially compatible with my C++ TRACE macros/module.

View File

@@ -29,7 +29,11 @@
const ENABLED_MODULES = window.ENABLED_MODULES || [];
function getTimestamp() {
return new Date().toISOString();
const now = new Date();
const offset = -now.getTimezoneOffset();
const pad = num => String(num).padStart(2, '0');
return `${now.getFullYear()}-${pad(now.getMonth() + 1)}-${pad(now.getDate())}T${pad(now.getHours())}:${pad(now.getMinutes())}:${pad(now.getSeconds())}.${String(now.getMilliseconds()).padStart(3, '0')}${offset >= 0 ? '+' : '-'}${pad(Math.floor(Math.abs(offset) / 60))}:${pad(Math.abs(offset) % 60)}`;
}
function getCurrentScriptName() {