From 48be8b11a3f2ec792d04bbbcbb13dba54c10cabf Mon Sep 17 00:00:00 2001 From: zhaolu <1977573921@qq.com> Date: Tue, 26 Aug 2025 09:12:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8B=B1=E6=96=87=E6=A8=A1?= =?UTF-8?q?=E5=BC=8F=E4=B8=8B=EF=BC=8C=E9=80=9A=E7=9F=A5=E4=B8=AD=E5=BF=83?= =?UTF-8?q?=E6=97=A5=E6=9C=9F=E6=A0=BC=E5=BC=8F=E6=98=BE=E7=A4=BA=E9=94=99?= =?UTF-8?q?=E8=AF=AF?= 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 | 7 +++++++ .../dropdownpanel/src/main/ets/pages/notification.ets | 6 +----- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/common/src/main/ets/default/TimeManager.ts b/common/src/main/ets/default/TimeManager.ts index 2394f58b..c8669b7f 100644 --- a/common/src/main/ets/default/TimeManager.ts +++ b/common/src/main/ets/default/TimeManager.ts @@ -24,6 +24,7 @@ import { obtainLocalEvent } from "./event/EventUtil"; import Constants from "./Constants"; import { CommonEventManager, getCommonEventManager, POLICY } from "./commonEvent/CommonEventManager"; import i18n from '@ohos.i18n'; +import intl from "@ohos.intl"; export const TIME_CHANGE_EVENT = "Time_Change_Event"; @@ -78,6 +79,12 @@ class TimeManager { return concatTime(date.getHours() % (this.mUse24hFormat ? 24 : 12), date.getMinutes()); } + public formatDate(date: Date): string { + let config: intl.DateTimeOptions = { weekday: 'long', month: 'long', day: 'numeric' }; + let dateTimeFormat: intl.DateTimeFormat = new intl.DateTimeFormat(i18n.System.getSystemLanguage(), config); + return dateTimeFormat.format(date); + } + private async initTimeFormat(context: any): Promise { Log.showDebug(TAG, "initTimeFormat"); if (context == undefined || context == null) { diff --git a/product/phone/dropdownpanel/src/main/ets/pages/notification.ets b/product/phone/dropdownpanel/src/main/ets/pages/notification.ets index f5b8ed56..5d48746f 100644 --- a/product/phone/dropdownpanel/src/main/ets/pages/notification.ets +++ b/product/phone/dropdownpanel/src/main/ets/pages/notification.ets @@ -270,11 +270,7 @@ struct CenterTitle { async updateTimeString(date: Date) { this.mTime = TimeManager.formatTime(date); Log.showDebug(TAG, ` month is ${date.getMonth() + 1} , day is ${date.getDate()} , week is ${Constants.WEEKDAY_LIST[date.getDay() - 1]}`); - await ResourceUtil.initResourceManager(AbilityManager.ABILITY_NAME_DROPDOWN_PANEL); - let timeString = (date.getMonth() + 1) + (await ResourceUtil.getString($r('app.string.month'))); - timeString += date.getDate() + (await ResourceUtil.getString($r('app.string.day'))); - timeString += await ResourceUtil.getString(Constants.WEEKDAY_LIST[date.getDay()]); - this.mTimeString = timeString; + this.mTimeString = TimeManager.formatDate(date); } settingClick() { -- Gitee