@tryghost/pretty-stream
Advanced tools
Comparing version
@@ -104,14 +104,20 @@ const dateFormat = require('date-format'); | ||
// Convert the time to UTC | ||
const now = new Date(); | ||
const dataTime = new Date(data.time || now); | ||
// Handle time formatting | ||
let time; | ||
// If the timezone offset is equal to the current timezone offset, and that timezone offset is not 0, | ||
// then we need to adjust the time | ||
if (dataTime.getTimezoneOffset() === now.getTimezoneOffset() && dataTime.getTimezoneOffset() !== 0) { | ||
dataTime.setMinutes(dataTime.getMinutes() + dataTime.getTimezoneOffset()); | ||
if (data.time) { | ||
// If time is provided as a string in the expected format, use it directly | ||
if (typeof data.time === 'string' && /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/.test(data.time)) { | ||
time = data.time; | ||
} else { | ||
// Otherwise, parse and format it | ||
const dataTime = new Date(data.time); | ||
time = dateFormat.asString('yyyy-MM-dd hh:mm:ss', dataTime); | ||
} | ||
} else { | ||
// No time provided, use current time | ||
const now = new Date(); | ||
time = dateFormat.asString('yyyy-MM-dd hh:mm:ss', now); | ||
} | ||
const time = dateFormat.asString('yyyy-MM-dd hh:mm:ss', dataTime); | ||
let logLevel = _private.levelFromName[data.level].toUpperCase(); | ||
@@ -118,0 +124,0 @@ const codes = _private.colors[_private.colorForLevel[data.level]]; |
{ | ||
"name": "@tryghost/pretty-stream", | ||
"version": "0.1.29", | ||
"repository": "https://github.com/TryGhost/framework/tree/main/packages/pretty-stream", | ||
"version": "0.2.0", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/TryGhost/framework.git", | ||
"directory": "packages/pretty-stream" | ||
}, | ||
"author": "Ghost Foundation", | ||
@@ -32,3 +36,3 @@ "license": "MIT", | ||
}, | ||
"gitHead": "783b40c3ece6e1c9e293d09f2c069baa3e1110b2" | ||
"gitHead": "e395f1d79edee4aecc36e572bb402016a8ba9273" | ||
} |
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
10049
2.03%192
3.78%0
-100%