From 36d1e01008313509f47d1a25888b087abc112279 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Sat, 13 Sep 2025 02:18:23 +0800 Subject: [PATCH] fix the display format of the fiscal year start date not updated after changing the number system on user profile page --- .../base/FiscalYearStartSelectionBase.ts | 18 +++++++++++++-- src/components/common/DateTimePicker.vue | 23 ++++++++++++++----- .../desktop/FiscalYearStartSelect.vue | 1 + .../mobile/FiscalYearStartSelectionSheet.vue | 1 + src/locales/helpers.ts | 14 +++++------ .../settings/tabs/UserBasicSettingTab.vue | 1 + src/views/mobile/users/UserProfilePage.vue | 4 +++- 7 files changed, 46 insertions(+), 16 deletions(-) diff --git a/src/components/base/FiscalYearStartSelectionBase.ts b/src/components/base/FiscalYearStartSelectionBase.ts index 4feaa272..c17592bb 100644 --- a/src/components/base/FiscalYearStartSelectionBase.ts +++ b/src/components/base/FiscalYearStartSelectionBase.ts @@ -2,9 +2,14 @@ import { ref, computed } from 'vue'; import { useI18n } from '@/locales/helpers.ts'; +import { NumeralSystem } from '@/core/numeral.ts'; import type { MonthDay } from '@/core/datetime.ts'; import { FiscalYearStart } from '@/core/fiscalyear.ts'; +import { + isDefined +} from '@/lib/common.ts'; + import { getLocalDatetimeFromUnixTime, getThisYearFirstUnixTime, @@ -16,6 +21,7 @@ export interface CommonFiscalYearStartSelectionProps { disabled?: boolean; readonly?: boolean; label?: string; + numeralSystem?: number; } export interface CommonFiscalYearStartSelectionEmits { @@ -37,7 +43,7 @@ function getFiscalYearStartFromProps(props: CommonFiscalYearStartSelectionProps) } export function useFiscalYearStartSelectionBase(props: CommonFiscalYearStartSelectionProps) { - const { formatGregorianTextualMonthDayToGregorianLikeLongMonthDay } = useI18n(); + const { getCurrentNumeralSystemType, formatGregorianTextualMonthDayToGregorianLikeLongMonthDay } = useI18n(); const disabledDates = (date: Date) => { // Disable February 29 (leap day) @@ -46,6 +52,14 @@ export function useFiscalYearStartSelectionBase(props: CommonFiscalYearStartSele const selectedFiscalYearStart = ref(getFiscalYearStartFromProps(props)); + const actualNumeralSystem = computed(() => { + if (isDefined(props.numeralSystem)) { + return NumeralSystem.valueOf(props.numeralSystem) ?? NumeralSystem.Default; + } else { + return getCurrentNumeralSystemType(); + } + }); + const selectedFiscalYearStartValue = computed({ get: () => { const fiscalYearStart = FiscalYearStart.valueOf(selectedFiscalYearStart.value); @@ -71,7 +85,7 @@ export function useFiscalYearStartSelectionBase(props: CommonFiscalYearStartSele fiscalYearStart = FiscalYearStart.Default; } - return formatGregorianTextualMonthDayToGregorianLikeLongMonthDay(fiscalYearStart.toMonthDashDayString()); + return formatGregorianTextualMonthDayToGregorianLikeLongMonthDay(fiscalYearStart.toMonthDashDayString(), actualNumeralSystem.value); }); const allowedMinDate = computed(() => getLocalDatetimeFromUnixTime(getThisYearFirstUnixTime())); diff --git a/src/components/common/DateTimePicker.vue b/src/components/common/DateTimePicker.vue index 82bb2465..c317aca7 100644 --- a/src/components/common/DateTimePicker.vue +++ b/src/components/common/DateTimePicker.vue @@ -55,8 +55,9 @@ import { useI18n } from '@/locales/helpers.ts'; import { useUserStore } from '@/stores/user.ts'; import type { CalendarType } from '@/core/calendar.ts'; +import { NumeralSystem } from '@/core/numeral.ts'; import type { PresetDateRange, WeekDayValue } from '@/core/datetime.ts'; -import { isArray, arrangeArrayWithNewStartIndex } from '@/lib/common.ts'; +import { isDefined, isArray, arrangeArrayWithNewStartIndex } from '@/lib/common.ts'; import { getAllowedYearRange, getYearMonthDayDateTime } from '@/lib/datetime.ts'; type VueDatePickerType = InstanceType; @@ -66,6 +67,7 @@ const props = defineProps<{ modelValue: SupportedModelValue; datetimePickerClass?: string; isDarkMode: boolean; + numeralSystem?: number; enableTimePicker: boolean; disableYearSelect?: boolean; vertical?: boolean; @@ -86,6 +88,7 @@ const { tt, getAllMinWeekdayNames, getCurrentCalendarDisplayType, + getCurrentNumeralSystemType, isLongDateMonthAfterYear, isLongTime24HourFormat, getCalendarDisplayShortYearFromUnixTime, @@ -106,6 +109,14 @@ const isYearFirst = computed(() => isLongDateMonthAfterYear()); const is24Hour = computed(() => isLongTime24HourFormat()); const alternateCalendarType = computed(() => getCurrentCalendarDisplayType().secondaryCalendarType); +const actualNumeralSystem = computed(() => { + if (isDefined(props.numeralSystem)) { + return NumeralSystem.valueOf(props.numeralSystem) ?? NumeralSystem.Default; + } else { + return getCurrentNumeralSystemType(); + } +}); + const dateTime = computed({ get: () => props.modelValue, set: (value: SupportedModelValue) => emit('update:modelValue', value) @@ -130,21 +141,21 @@ function switchView(viewType: MenuView): void { } function getDisplayYear(year: number): string { - return getCalendarDisplayShortYearFromUnixTime(getYearMonthDayDateTime(year, 1, 1).getUnixTime()); + return getCalendarDisplayShortYearFromUnixTime(getYearMonthDayDateTime(year, 1, 1).getUnixTime(), actualNumeralSystem.value); } function getDisplayMonth(month: number): string { if (isArray(dateTime.value)) { - return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value[0].getFullYear(), month + 1, 1).getUnixTime()); + return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value[0].getFullYear(), month + 1, 1).getUnixTime(), actualNumeralSystem.value); } else if (dateTime.value) { - return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value.getFullYear(), month + 1, 1).getUnixTime()); + return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value.getFullYear(), month + 1, 1).getUnixTime(), actualNumeralSystem.value); } else { - return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(new Date().getFullYear(), month + 1, 1).getUnixTime()); + return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(new Date().getFullYear(), month + 1, 1).getUnixTime(), actualNumeralSystem.value); } } function getDisplayDay(date: Date): string { - return getCalendarDisplayDayOfMonthFromUnixTime(getYearMonthDayDateTime(date.getFullYear(), date.getMonth() + 1, date.getDate()).getUnixTime()); + return getCalendarDisplayDayOfMonthFromUnixTime(getYearMonthDayDateTime(date.getFullYear(), date.getMonth() + 1, date.getDate()).getUnixTime(), actualNumeralSystem.value); } defineExpose({ diff --git a/src/components/desktop/FiscalYearStartSelect.vue b/src/components/desktop/FiscalYearStartSelect.vue index 0016896d..9fc0d18f 100644 --- a/src/components/desktop/FiscalYearStartSelect.vue +++ b/src/components/desktop/FiscalYearStartSelect.vue @@ -13,6 +13,7 @@