From b2ee311992b09e27b4932380307ac72f32ab5e52 Mon Sep 17 00:00:00 2001 From: zhaolu <1977573921@qq.com> Date: Mon, 25 Aug 2025 10:00:44 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=B6=E9=97=B4=E8=AE=BE?= =?UTF-8?q?=E7=BD=AE=E4=B8=BA12=E5=B0=8F=E6=97=B6=E5=88=B6=E6=97=B6?= =?UTF-8?q?=EF=BC=8C12=E7=82=B9=E6=98=BE=E7=A4=BA=E4=B8=BA=E4=BA=860?= =?UTF-8?q?=E7=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: zhaolu <1977573921@qq.com> --- common/src/main/ets/default/TimeManager.ts | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/common/src/main/ets/default/TimeManager.ts b/common/src/main/ets/default/TimeManager.ts index 6a5c81ca..bf0704f2 100644 --- a/common/src/main/ets/default/TimeManager.ts +++ b/common/src/main/ets/default/TimeManager.ts @@ -73,7 +73,17 @@ class TimeManager { } public formatTime(date: Date) { - return concatTime(date.getHours() % (this.mUse24hFormat ? 24 : 12), date.getMinutes()); + let hours = date.getHours(); + if (this.mUse24hFormat) { + hours = hours % 24; + } else { + hours = hours % 12; + // hours should show 12, not 0. + if (hours == 0) { + hours = 12; + } + } + return concatTime(hours, date.getMinutes()); } private async initTimeFormat(context: any): Promise { -- Gitee