From 1b6c587cc9eb34ec9638b81da7d9d29f9f1a4e9b Mon Sep 17 00:00:00 2001 From: Louis Lam Date: Mon, 26 Dec 2022 14:46:12 +0800 Subject: [PATCH] Fix #2472 --- src/util.js | 8 +++++++- src/util.ts | 7 ++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/util.js b/src/util.js index f157e9e92..09e6d0ee7 100644 --- a/src/util.js +++ b/src/util.js @@ -106,7 +106,13 @@ class Logger { } module = module.toUpperCase(); level = level.toUpperCase(); - const now = dayjs.tz(new Date()).format(); + let now; + if (dayjs.tz) { + now = dayjs.tz(new Date()).format(); + } + else { + now = dayjs().format(); + } const formattedMessage = (typeof msg === "string") ? `${now} [${module}] ${level}: ${msg}` : msg; if (level === "INFO") { console.info(formattedMessage); diff --git a/src/util.ts b/src/util.ts index 6d3aabeb6..99038c8d3 100644 --- a/src/util.ts +++ b/src/util.ts @@ -122,7 +122,12 @@ class Logger { module = module.toUpperCase(); level = level.toUpperCase(); - const now = dayjs.tz(new Date()).format(); + let now; + if (dayjs.tz) { + now = dayjs.tz(new Date()).format(); + } else { + now = dayjs().format(); + } const formattedMessage = (typeof msg === "string") ? `${now} [${module}] ${level}: ${msg}` : msg; if (level === "INFO") {