From 2cbd24b0bd95342c0a6797b1d3be8788865ef353 Mon Sep 17 00:00:00 2001 From: loom Date: Sat, 28 Nov 2026 15:44:29 +0000 Subject: [PATCH] loom: implement issue #15 --- miniprogram/utils/index.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/miniprogram/utils/index.js b/miniprogram/utils/index.js index c2e347f..485b35b 100644 --- a/miniprogram/utils/index.js +++ b/miniprogram/utils/index.js @@ -1,4 +1,5 @@ -const formatTime = date => { +const formatTime = (date, options = {}) => { + const { includeSeconds = true } = options || {} const year = date.getFullYear() const month = date.getMonth() + 1 const day = date.getDate() @@ -6,7 +7,11 @@ const formatTime = date => { const minute = date.getMinutes() const second = date.getSeconds() - return `${[year, month, day].map(formatNumber).join('/')} ${[hour, minute, second].map(formatNumber).join(':')}` + const time = includeSeconds + ? [hour, minute, second].map(formatNumber).join(':') + : [hour, minute].map(formatNumber).join(':') + + return `${[year, month, day].map(formatNumber).join('/')} ${time}` } const formatNumber = n => {