From 1003564bd79ec3f778a080000526e45994950ecb Mon Sep 17 00:00:00 2001 From: Andrey Sitnik Date: Wed, 7 Aug 2024 00:20:45 +0200 Subject: [PATCH] Typo --- human-formatter/index.js | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/human-formatter/index.js b/human-formatter/index.js index a8ac15d..f15a9f9 100644 --- a/human-formatter/index.js +++ b/human-formatter/index.js @@ -38,13 +38,14 @@ const LABELS = { const COLORS = ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan'] -function formatTime(date) { - const year = date.getFullYear() - const month = String(date.getMonth() + 1).padStart(2, '0') - const day = String(date.getDate()).padStart(2, '0') - const hour = String(date.getHours()).padStart(2, '0') - const minutes = String(date.getMinutes()).padStart(2, '0') - const seconds = String(date.getSeconds()).padStart(2, '0') +function formatNow() { + let date = new Date() + let year = date.getFullYear() + let month = String(date.getMonth() + 1).padStart(2, '0') + let day = String(date.getDate()).padStart(2, '0') + let hour = String(date.getHours()).padStart(2, '0') + let minutes = String(date.getMinutes()).padStart(2, '0') + let seconds = String(date.getSeconds()).padStart(2, '0') return `${year}-${month}-${day} ${hour}:${minutes}:${seconds}` } @@ -56,7 +57,7 @@ function rightPag(str, length) { function label(c, type, color, labelBg, labelText, message) { let pagged = rightPag(c[labelBg](c[labelText](type)), 8) - let time = c.dim(`at ${yyyymmdd.withTime(new Date())}`) + let time = c.dim(`at ${formatNow()}`) let highlighted = message.replace(/`([^`]+)`/g, c.yellow('$1')) return `${pagged}${c.bold(c[color](highlighted))} ${time}` }