mirror of
https://github.com/Pablo2048/trace.js.git
synced 2025-10-30 16:11:52 +01:00
Merge pull request #1 from Pablo2048/development
Local time in timestamp
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user