diff --git a/common/src/main/ets/default/TimeManager.ts b/common/src/main/ets/default/TimeManager.ts index 6a5c81cac238175abf2062f77937ba052b563f41..4b409e4b54f91a39d7b5abea4c71973dec738948 100644 --- a/common/src/main/ets/default/TimeManager.ts +++ b/common/src/main/ets/default/TimeManager.ts @@ -23,6 +23,8 @@ import createOrGet from "./SingleInstanceHelper"; 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"; @@ -76,6 +78,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"); settings.getValueSync(context, TIME_FORMAT_KEY, "24"); diff --git a/features/locationcomponent/src/main/ets/com/ohos/model/LocationService.ts b/features/locationcomponent/src/main/ets/com/ohos/model/LocationService.ts index b88e8a05dfdad5a160f0bcb1b0b859483db5dc74..36de38e0a25df74ecc2e543c349bc2deb7249dfb 100644 --- a/features/locationcomponent/src/main/ets/com/ohos/model/LocationService.ts +++ b/features/locationcomponent/src/main/ets/com/ohos/model/LocationService.ts @@ -51,9 +51,7 @@ export class LocationService { Log.showInfo(TAG, 'stopService'); this.mIsStart = false; try { - geolocation.off('locationEnabledChange', (state: boolean) => { - Log.showInfo(TAG, `stopService locationChange, state: ${JSON.stringify(state)}`) - }); + geolocation.off('locationEnabledChange'); } catch { Log.showError(TAG, 'geolocation.off try-catch error'); } 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() {