diff --git a/common/src/main/ets/default/TimeManager.ts b/common/src/main/ets/default/TimeManager.ts index e4e34ecd10d259116d7c6d84d0f22c3c29fbfe8a..eef0f8ba27c11c8a7a878186f1bb050e4b1d9bf8 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"; @@ -79,6 +80,12 @@ class TimeManager { return concatTime(date.getHours() % (format ? 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 5e55f2f3c0cbb4d931821d7bd4c0526ab64e6a72..4f85bec2cee008eac4346e10c6ed16796b469d37 100644 --- a/product/phone/dropdownpanel/src/main/ets/pages/notification.ets +++ b/product/phone/dropdownpanel/src/main/ets/pages/notification.ets @@ -271,11 +271,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 = TimeManagere.formatDate(date); } settingClick() {