diff --git a/common/src/main/ets/default/TimeManager.ts b/common/src/main/ets/default/TimeManager.ts index 2394f58b1491d431dd6d5c9c8fb27fea64b70a37..c8669b7f66274c2fe1568e45079a18a20b659952 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 f5b8ed56fd6260db492dde8f9f8ad3905bbb5204..5d48746f95129e55530cc1f22dc0f10c22647684 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() {