From 642e51bc0c4b376ca1f633f4580031764609d0a7 Mon Sep 17 00:00:00 2001 From: MaysWind Date: Mon, 8 Sep 2025 00:32:30 +0800 Subject: [PATCH] use and display the Gregorian calendar when calculating months, quarters, years, and fiscal years --- .../base/AccountBalanceTrendsChartBase.ts | 16 ++- .../base/FiscalYearStartSelectionBase.ts | 4 +- .../base/MonthRangeSelectionBase.ts | 6 +- src/components/desktop/MonthlyTrendsChart.vue | 16 +-- .../mobile/MonthlyTrendsBarChart.vue | 16 +-- src/lib/datetime.ts | 12 +-- src/locales/helpers.ts | 101 +++++++++--------- src/views/base/HomePageBase.ts | 18 ++-- .../StatisticsTransactionPageBase.ts | 6 +- .../transactions/TransactionListPageBase.ts | 4 +- .../cards/MonthlyIncomeAndExpenseCard.vue | 9 +- .../mobile/settings/TextSizeSettingsPage.vue | 8 +- src/views/mobile/transactions/ListPage.vue | 4 +- src/views/mobile/users/UserProfilePage.vue | 4 +- 14 files changed, 120 insertions(+), 104 deletions(-) diff --git a/src/components/base/AccountBalanceTrendsChartBase.ts b/src/components/base/AccountBalanceTrendsChartBase.ts index 82453cc0..38175e68 100644 --- a/src/components/base/AccountBalanceTrendsChartBase.ts +++ b/src/components/base/AccountBalanceTrendsChartBase.ts @@ -51,7 +51,13 @@ export interface CommonAccountBalanceTrendsChartProps { } export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTrendsChartProps) { - const { formatUnixTimeToShortDate, formatUnixTimeToShortYear, formatUnixTimeToShortYearMonth, formatUnixTimeToYearQuarter, formatUnixTimeToFiscalYear } = useI18n(); + const { + getCalendarShortYearFromUnixTime, + getCalendarShortYearMonthFromUnixTime, + getCalendarYearQuarterFromUnixTime, + getCalendarFiscalYearFromUnixTime, + formatUnixTimeToShortDate + } = useI18n(); const dataDateRange = computed(() => { if (!props.items || props.items.length < 1) { @@ -150,13 +156,13 @@ export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTren let displayDate = ''; if (props.dateAggregationType === ChartDateAggregationType.Year.type) { - displayDate = formatUnixTimeToShortYear(dateRange.minUnixTime); + displayDate = getCalendarShortYearFromUnixTime(dateRange.minUnixTime); } else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type) { - displayDate = formatUnixTimeToFiscalYear(dateRange.minUnixTime); + displayDate = getCalendarFiscalYearFromUnixTime(dateRange.minUnixTime); } else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type) { - displayDate = formatUnixTimeToYearQuarter(dateRange.minUnixTime); + displayDate = getCalendarYearQuarterFromUnixTime(dateRange.minUnixTime); } else if (props.dateAggregationType === ChartDateAggregationType.Month.type) { - displayDate = formatUnixTimeToShortYearMonth(dateRange.minUnixTime); + displayDate = getCalendarShortYearMonthFromUnixTime(dateRange.minUnixTime); } else { displayDate = formatUnixTimeToShortDate(dateRange.minUnixTime); } diff --git a/src/components/base/FiscalYearStartSelectionBase.ts b/src/components/base/FiscalYearStartSelectionBase.ts index 33528a3a..2f58edfc 100644 --- a/src/components/base/FiscalYearStartSelectionBase.ts +++ b/src/components/base/FiscalYearStartSelectionBase.ts @@ -37,7 +37,7 @@ function getFiscalYearStartFromProps(props: CommonFiscalYearStartSelectionProps) } export function useFiscalYearStartSelectionBase(props: CommonFiscalYearStartSelectionProps) { - const { formatGregorianCalendarMonthDashDayToLongMonthDay } = useI18n(); + const { getCalendarLongMonthDayFromGregorianCalendarTextualMonthDay } = useI18n(); const disabledDates = (date: Date) => { // Disable February 29 (leap day) @@ -71,7 +71,7 @@ export function useFiscalYearStartSelectionBase(props: CommonFiscalYearStartSele fiscalYearStart = FiscalYearStart.Default; } - return formatGregorianCalendarMonthDashDayToLongMonthDay(fiscalYearStart.toMonthDashDayString()); + return getCalendarLongMonthDayFromGregorianCalendarTextualMonthDay(fiscalYearStart.toMonthDashDayString()); }); const allowedMinDate = computed(() => getLocalDatetimeFromUnixTime(getThisYearFirstUnixTime())); diff --git a/src/components/base/MonthRangeSelectionBase.ts b/src/components/base/MonthRangeSelectionBase.ts index c7e3f887..a882e4d8 100644 --- a/src/components/base/MonthRangeSelectionBase.ts +++ b/src/components/base/MonthRangeSelectionBase.ts @@ -49,7 +49,7 @@ function getMonthRangeFromProps(props: CommonMonthRangeSelectionProps): { minDat } export function useMonthRangeSelectionBase(props: CommonMonthRangeSelectionProps) { - const { formatUnixTimeToLongYearMonth } = useI18n(); + const { getCalendarLongYearMonthFromUnixTime } = useI18n(); const { minDate, maxDate } = getMonthRangeFromProps(props); const dateRange = ref([ @@ -57,8 +57,8 @@ export function useMonthRangeSelectionBase(props: CommonMonthRangeSelectionProps maxDate ]); - const beginDateTime = computed(() => formatUnixTimeToLongYearMonth(getYearMonthFirstUnixTime(dateRange.value[0]))); - const endDateTime = computed(() => formatUnixTimeToLongYearMonth(getYearMonthLastUnixTime(dateRange.value[1]))); + const beginDateTime = computed(() => getCalendarLongYearMonthFromUnixTime(getYearMonthFirstUnixTime(dateRange.value[0]))); + const endDateTime = computed(() => getCalendarLongYearMonthFromUnixTime(getYearMonthLastUnixTime(dateRange.value[1]))); function getFinalMonthRange(): { minYearMonth: TextualYearMonth | '', maxYearMonth: TextualYearMonth | '' } | null { if (!dateRange.value[0] || !dateRange.value[1]) { diff --git a/src/components/desktop/MonthlyTrendsChart.vue b/src/components/desktop/MonthlyTrendsChart.vue index a80eff98..a5cbc05a 100644 --- a/src/components/desktop/MonthlyTrendsChart.vue +++ b/src/components/desktop/MonthlyTrendsChart.vue @@ -80,10 +80,10 @@ const theme = useTheme(); const { tt, getCurrentLanguageTextDirection, - formatUnixTimeToShortYear, - formatYearQuarter, - formatUnixTimeToShortYearMonth, - formatUnixTimeToFiscalYear, + getCalendarShortYearFromUnixTime, + getCalendarShortYearMonthFromUnixTime, + getCalendarYearQuarterFromYearQuarter, + getCalendarFiscalYearFromUnixTime, formatAmountToWesternArabicNumeralsWithoutDigitGrouping, formatAmountToLocalizedNumeralsWithCurrency } = useI18n(); @@ -139,13 +139,13 @@ const allDisplayDateRanges = computed(() => { const dateRange = allDateRanges.value[i]; if (props.dateAggregationType === ChartDateAggregationType.Year.type) { - allDisplayDateRanges.push(formatUnixTimeToShortYear(dateRange.minUnixTime)); + allDisplayDateRanges.push(getCalendarShortYearFromUnixTime(dateRange.minUnixTime)); } else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type && 'year' in dateRange) { - allDisplayDateRanges.push(formatUnixTimeToFiscalYear(dateRange.minUnixTime)); + allDisplayDateRanges.push(getCalendarFiscalYearFromUnixTime(dateRange.minUnixTime)); } else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type && 'quarter' in dateRange) { - allDisplayDateRanges.push(formatYearQuarter(dateRange.year, dateRange.quarter)); + allDisplayDateRanges.push(getCalendarYearQuarterFromYearQuarter(dateRange.year, dateRange.quarter)); } else { // if (props.dateAggregationType === ChartDateAggregationType.Month.type) { - allDisplayDateRanges.push(formatUnixTimeToShortYearMonth(dateRange.minUnixTime)); + allDisplayDateRanges.push(getCalendarShortYearMonthFromUnixTime(dateRange.minUnixTime)); } } diff --git a/src/components/mobile/MonthlyTrendsBarChart.vue b/src/components/mobile/MonthlyTrendsBarChart.vue index a6c3ea73..6be94885 100644 --- a/src/components/mobile/MonthlyTrendsBarChart.vue +++ b/src/components/mobile/MonthlyTrendsBarChart.vue @@ -156,10 +156,10 @@ const emit = defineEmits<{ const { tt, - formatUnixTimeToShortYear, - formatYearQuarter, - formatUnixTimeToShortYearMonth, - formatUnixTimeToFiscalYear, + getCalendarShortYearFromUnixTime, + getCalendarShortYearMonthFromUnixTime, + getCalendarYearQuarterFromYearQuarter, + getCalendarFiscalYearFromUnixTime, formatAmountToLocalizedNumeralsWithCurrency } = useI18n(); @@ -250,13 +250,13 @@ const allDisplayDataItems = computed(() => { let displayDateRange = ''; if (props.dateAggregationType === ChartDateAggregationType.Year.type) { - displayDateRange = formatUnixTimeToShortYear(dateRange.minUnixTime); + displayDateRange = getCalendarShortYearFromUnixTime(dateRange.minUnixTime); } else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type) { - displayDateRange = formatUnixTimeToFiscalYear(dateRange.minUnixTime); + displayDateRange = getCalendarFiscalYearFromUnixTime(dateRange.minUnixTime); } else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type && 'quarter' in dateRange) { - displayDateRange = formatYearQuarter(dateRange.year, dateRange.quarter); + displayDateRange = getCalendarYearQuarterFromYearQuarter(dateRange.year, dateRange.quarter); } else { // if (props.dateAggregationType === ChartDateAggregationType.Month.type) { - displayDateRange = formatUnixTimeToShortYearMonth(dateRange.minUnixTime); + displayDateRange = getCalendarShortYearMonthFromUnixTime(dateRange.minUnixTime); } const dataItems = allDateRangeItemsMap[dateRangeKey] || []; diff --git a/src/lib/datetime.ts b/src/lib/datetime.ts index 472e4560..aea86c0a 100644 --- a/src/lib/datetime.ts +++ b/src/lib/datetime.ts @@ -368,25 +368,25 @@ class MomentDateTime implements DateTime { return this.persianDateInfo; } - static isYearFirstTime(dateTime: MomentDateTime): boolean { + static isGregorianCalendarYearFirstTime(dateTime: MomentDateTime): boolean { const currentUnixTime = dateTime.instance.clone().set({ millisecond: 0 }).unix(); const expectedUnxTime = dateTime.instance.clone().set({ millisecond: 0 }).startOf('year').unix(); return currentUnixTime === expectedUnxTime; } - static isYearLastTime(dateTime: MomentDateTime): boolean { + static isGregorianCalendarYearLastTime(dateTime: MomentDateTime): boolean { const currentUnixTime = dateTime.instance.clone().set({ millisecond: 999 }).unix(); const expectedUnxTime = dateTime.instance.clone().set({ millisecond: 999 }).endOf('year').unix(); return currentUnixTime === expectedUnxTime; } - static isMonthFirstTime(dateTime: MomentDateTime): boolean { + static isGregorianCalendarMonthFirstTime(dateTime: MomentDateTime): boolean { const currentUnixTime = dateTime.instance.clone().set({ millisecond: 0 }).unix(); const expectedUnxTime = dateTime.instance.clone().set({ millisecond: 0 }).startOf('month').unix(); return currentUnixTime === expectedUnxTime; } - static isMonthLastTime(dateTime: MomentDateTime): boolean { + static isGregorianCalendarMonthLastTime(dateTime: MomentDateTime): boolean { const currentUnixTime = dateTime.instance.clone().set({ millisecond: 999 }).unix(); const expectedUnxTime = dateTime.instance.clone().set({ millisecond: 999 }).endOf('month').unix(); return currentUnixTime === expectedUnxTime; @@ -1373,13 +1373,13 @@ export function getValidMonthDayOrCurrentDayShortDate(unixTime: number, currentS export function isDateRangeMatchFullYears(minTime: number, maxTime: number): boolean { const minDateTime = parseDateTimeFromUnixTime(minTime); const maxDateTime = parseDateTimeFromUnixTime(maxTime); - return MomentDateTime.isYearFirstTime(minDateTime as MomentDateTime) && MomentDateTime.isYearLastTime(maxDateTime as MomentDateTime); + return MomentDateTime.isGregorianCalendarYearFirstTime(minDateTime as MomentDateTime) && MomentDateTime.isGregorianCalendarYearLastTime(maxDateTime as MomentDateTime); } export function isDateRangeMatchFullMonths(minTime: number, maxTime: number): boolean { const minDateTime = parseDateTimeFromUnixTime(minTime); const maxDateTime = parseDateTimeFromUnixTime(maxTime); - return MomentDateTime.isMonthFirstTime(minDateTime as MomentDateTime) && MomentDateTime.isMonthLastTime(maxDateTime as MomentDateTime); + return MomentDateTime.isGregorianCalendarMonthFirstTime(minDateTime as MomentDateTime) && MomentDateTime.isGregorianCalendarMonthLastTime(maxDateTime as MomentDateTime); } export function isDateRangeMatchOneMonth(minTime: number, maxTime: number): boolean { diff --git a/src/locales/helpers.ts b/src/locales/helpers.ts index 007a7d53..edf6209b 100644 --- a/src/locales/helpers.ts +++ b/src/locales/helpers.ts @@ -778,6 +778,30 @@ export function useI18n() { return ''; } + function formatTimeRangeToFiscalYearFormat(format: FiscalYearFormat, timeRange: FiscalYearUnixTime | UnixTimeRange, numeralSystem?: NumeralSystem, calendarType?: CalendarType): string { + if (!format) { + format = FiscalYearFormat.Default; + } + + const currentCalendarDisplayType = getCurrentCalendarDisplayType(); + + if (!isDefined(calendarType)) { + calendarType = currentCalendarDisplayType.primaryCalendarType; + } + + const dateTimeFormatOptions = getDateTimeFormatOptions({ + calendarType: calendarType, + numeralSystem: numeralSystem + }); + + return t('format.fiscalYear.' + format.typeName, { + StartYYYY: formatUnixTime(timeRange.minUnixTime, 'YYYY', dateTimeFormatOptions), + StartYY: formatUnixTime(timeRange.minUnixTime, 'YY', dateTimeFormatOptions), + EndYYYY: formatUnixTime(timeRange.maxUnixTime, 'YYYY', dateTimeFormatOptions), + EndYY: formatUnixTime(timeRange.maxUnixTime, 'YY', dateTimeFormatOptions), + }); + } + function getCurrentCurrencyDisplayType(): CurrencyDisplayType { let currencyDisplayType = CurrencyDisplayType.valueOf(userStore.currentUserCurrencyDisplayType); @@ -1099,7 +1123,8 @@ export function useI18n() { function getAllRecentMonthDateRanges(includeAll: boolean, includeCustom: boolean): LocalizedRecentMonthDateRange[] { const allRecentMonthDateRanges: LocalizedRecentMonthDateRange[] = []; const recentDateRanges = getRecentMonthDateRanges(12); - const dateTimeFormatOptions = getDateTimeFormatOptions(); + const currentCalendarDisplayType = getCurrentCalendarDisplayType(); + const dateTimeFormatOptions = getDateTimeFormatOptions({ calendarType: currentCalendarDisplayType.primaryCalendarType }); if (includeAll) { allRecentMonthDateRanges.push({ @@ -1782,23 +1807,21 @@ export function useI18n() { return getLocalizedLongTimeFormat().indexOf('ss') >= 0; } - function formatGregorianCalendarYearDashMonthDashDayToLongDate(date: TextualYearMonthDay): string { - return formatGregorianCalendarYearDashMonthDashDay(date, getLocalizedLongDateFormat(), getDateTimeFormatOptions()); + function getCalendarLongMonthDayFromGregorianCalendarTextualMonthDay(monthDay: TextualYearMonth): string { + const currentCalendarDisplayType = getCurrentCalendarDisplayType(); + return formatGregorianCalendarMonthDashDay(monthDay, getLocalizedLongMonthDayFormat(), getDateTimeFormatOptions({ calendarType: currentCalendarDisplayType.primaryCalendarType })); } - function formatGregorianCalendarMonthDashDayToLongMonthDay(monthDay: TextualYearMonth): string { - return formatGregorianCalendarMonthDashDay(monthDay, getLocalizedLongMonthDayFormat(), getDateTimeFormatOptions()); - } - - function formatUnixTimeToYearQuarter(unixTime: number): string { - const dateTimeFormatOptions = getDateTimeFormatOptions(); + function getCalendarYearQuarterFromUnixTime(unixTime: number): string { + const currentCalendarDisplayType = getCurrentCalendarDisplayType(); + const dateTimeFormatOptions = getDateTimeFormatOptions({ calendarType: currentCalendarDisplayType.primaryCalendarType }); const date = parseDateTimeFromUnixTime(unixTime); const year = date.getLocalizedCalendarYear(dateTimeFormatOptions); const quarter = date.getLocalizedCalendarQuarter(dateTimeFormatOptions); - return formatYearQuarter(year, quarter); + return getCalendarYearQuarterFromYearQuarter(year, quarter); } - function formatYearQuarter(year: number | string, quarter: number): string { + function getCalendarYearQuarterFromYearQuarter(year: number | string, quarter: number): string { if (1 <= quarter && quarter <= 4) { return t('format.yearQuarter.q' + quarter, { year: year, @@ -1815,7 +1838,8 @@ export function useI18n() { } const allDateRanges = DateRange.values(); - const dateTimeFormatOptions = getDateTimeFormatOptions(); + const currentCalendarDisplayType = getCurrentCalendarDisplayType(); + const dateTimeFormatOptions = getDateTimeFormatOptions({ calendarType: currentCalendarDisplayType.primaryCalendarType }); for (let i = 0; i < allDateRanges.length; i++) { const dateRange = allDateRanges[i]; @@ -1858,22 +1882,7 @@ export function useI18n() { return `${displayStartTime} ~ ${displayEndTime}`; } - function formatTimeRangeToFiscalYearFormat(format: FiscalYearFormat, timeRange: FiscalYearUnixTime | UnixTimeRange, numeralSystem?: NumeralSystem, calendarType?: CalendarType): string { - if (!format) { - format = FiscalYearFormat.Default; - } - - const dateTimeFormatOptions = getDateTimeFormatOptions({ numeralSystem, calendarType }); - - return t('format.fiscalYear.' + format.typeName, { - StartYYYY: formatUnixTime(timeRange.minUnixTime, 'YYYY', dateTimeFormatOptions), - StartYY: formatUnixTime(timeRange.minUnixTime, 'YY', dateTimeFormatOptions), - EndYYYY: formatUnixTime(timeRange.maxUnixTime, 'YYYY', dateTimeFormatOptions), - EndYY: formatUnixTime(timeRange.maxUnixTime, 'YY', dateTimeFormatOptions), - }); - } - - function formatUnixTimeToFiscalYear(unixTime: number): string { + function getCalendarFiscalYearFromUnixTime(unixTime: number): string { let fiscalYearFormat = FiscalYearFormat.valueOf(getCurrentFiscalYearFormatType()); if (!fiscalYearFormat) { @@ -1884,7 +1893,7 @@ export function useI18n() { return formatTimeRangeToFiscalYearFormat(fiscalYearFormat, timeRange); } - function formatYearToFiscalYear(year: number) { + function getCalendarFiscalYearGregorianCalendarYear(year: number) { let fiscalYearFormat = FiscalYearFormat.valueOf(getCurrentFiscalYearFormatType()); if (!fiscalYearFormat) { @@ -1895,14 +1904,14 @@ export function useI18n() { return formatTimeRangeToFiscalYearFormat(fiscalYearFormat, timeRange); } - function formatFiscalYearStartToLongDay(fiscalYearStartValue: number) { + function getCalendarLongMonthDayFromFiscalYearStart(fiscalYearStartValue: number) { let fiscalYearStart = FiscalYearStart.valueOf(fiscalYearStartValue); if (!fiscalYearStart) { fiscalYearStart = FiscalYearStart.Default; } - return formatGregorianCalendarMonthDashDayToLongMonthDay(fiscalYearStart.toMonthDashDayString()); + return getCalendarLongMonthDayFromGregorianCalendarTextualMonthDay(fiscalYearStart.toMonthDashDayString()); } function getTimezoneDifferenceDisplayText(utcOffset: number): string { @@ -2392,34 +2401,30 @@ export function useI18n() { isLongTimeMinuteTwoDigits, isLongTimeSecondTwoDigits, // format functions + getCalendarLongYearFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedLongYearFormat(), getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset), getCalendarShortYearFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortYearFormat(), getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset), + getCalendarLongMonthFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, 'MMMM', getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset), getCalendarShortMonthFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, 'MMM', getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset), getCalendarDayOfMonthFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortDayFormat(), getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset), + getCalendarLongYearMonthFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedLongYearMonthFormat(), getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset), + getCalendarShortYearMonthFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortYearMonthFormat(), getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset), + getCalendarLongMonthDayFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedLongMonthDayFormat(), getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset), + getCalendarShortMonthDayFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortMonthDayFormat(), getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset), + getCalendarYearQuarterFromUnixTime, + getCalendarYearQuarterFromYearQuarter, + getCalendarFiscalYearFromUnixTime, + getCalendarFiscalYearGregorianCalendarYear, + getCalendarLongMonthDayFromGregorianCalendarTextualMonthDay, + getCalendarLongMonthDayFromFiscalYearStart, formatUnixTimeToDefaultDateTimeWithoutLocaleOptions: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, KnownDateTimeFormat.DefaultDateTime.format, getDateTimeFormatOptions({ numeralSystem: NumeralSystem.WesternArabicNumerals, calendarType: CalendarType.Gregorian }), utcOffset, currentUtcOffset), formatUnixTimeToLongDateTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedLongDateFormat() + ' ' + getLocalizedLongTimeFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset), formatUnixTimeToShortDateTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortDateFormat() + ' ' + getLocalizedShortTimeFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset), formatUnixTimeToLongDate: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedLongDateFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset), formatUnixTimeToShortDate: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortDateFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset), - formatUnixTimeToLongYear: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedLongYearFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset), - formatUnixTimeToShortYear: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortYearFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset), - formatUnixTimeToLongMonth: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, 'MMMM', getDateTimeFormatOptions(), utcOffset, currentUtcOffset), - formatUnixTimeToShortMonth: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, 'MMM', getDateTimeFormatOptions(), utcOffset, currentUtcOffset), - formatUnixTimeToLongYearMonth: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedLongYearMonthFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset), - formatUnixTimeToShortYearMonth: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortYearMonthFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset), - formatUnixTimeToLongMonthDay: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedLongMonthDayFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset), - formatUnixTimeToShortMonthDay: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortMonthDayFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset), formatUnixTimeToLongTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedLongTimeFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset), formatUnixTimeToShortTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortTimeFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset), - formatUnixTimeToDayOfMonth: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortDayFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset), - formatGregorianCalendarYearDashMonthDashDayToLongDate, - formatGregorianCalendarMonthDashDayToLongMonthDay, - formatUnixTimeToYearQuarter, - formatYearQuarter, + formatGregorianCalendarYearDashMonthDashDayToLongDate: (date: TextualYearMonthDay) => formatGregorianCalendarYearDashMonthDashDay(date, getLocalizedLongDateFormat(), getDateTimeFormatOptions()), formatDateRange, - formatFiscalYearStartToLongDay, - formatTimeRangeToFiscalYearFormat, - formatUnixTimeToFiscalYear, - formatYearToFiscalYear, getTimezoneDifferenceDisplayText, getCalendarAlternateDates, getCalendarAlternateDate, diff --git a/src/views/base/HomePageBase.ts b/src/views/base/HomePageBase.ts index 7de38608..ec71dd42 100644 --- a/src/views/base/HomePageBase.ts +++ b/src/views/base/HomePageBase.ts @@ -20,9 +20,9 @@ import type { export function useHomePageBase() { const { formatUnixTimeToLongDate, - formatUnixTimeToLongYear, - formatUnixTimeToLongMonth, - formatUnixTimeToLongMonthDay, + getCalendarLongYearFromUnixTime, + getCalendarLongMonthFromUnixTime, + getCalendarLongMonthDayFromUnixTime, formatAmountToLocalizedNumeralsWithCurrency } = useI18n(); @@ -60,16 +60,16 @@ export function useHomePageBase() { displayTime: formatUnixTimeToLongDate(overviewStore.transactionDataRange.today.startTime), }, thisWeek: { - startTime: formatUnixTimeToLongMonthDay(overviewStore.transactionDataRange.thisWeek.startTime), - endTime: formatUnixTimeToLongMonthDay(overviewStore.transactionDataRange.thisWeek.endTime) + startTime: getCalendarLongMonthDayFromUnixTime(overviewStore.transactionDataRange.thisWeek.startTime), + endTime: getCalendarLongMonthDayFromUnixTime(overviewStore.transactionDataRange.thisWeek.endTime) }, thisMonth: { - displayTime: formatUnixTimeToLongMonth(overviewStore.transactionDataRange.thisMonth.startTime), - startTime: formatUnixTimeToLongMonthDay(overviewStore.transactionDataRange.thisMonth.startTime), - endTime: formatUnixTimeToLongMonthDay(overviewStore.transactionDataRange.thisMonth.endTime) + displayTime: getCalendarLongMonthFromUnixTime(overviewStore.transactionDataRange.thisMonth.startTime), + startTime: getCalendarLongMonthDayFromUnixTime(overviewStore.transactionDataRange.thisMonth.startTime), + endTime: getCalendarLongMonthDayFromUnixTime(overviewStore.transactionDataRange.thisMonth.endTime) }, thisYear: { - displayTime: formatUnixTimeToLongYear(overviewStore.transactionDataRange.thisYear.startTime) + displayTime: getCalendarLongYearFromUnixTime(overviewStore.transactionDataRange.thisYear.startTime) } }; }); diff --git a/src/views/base/statistics/StatisticsTransactionPageBase.ts b/src/views/base/statistics/StatisticsTransactionPageBase.ts index 76ec6bc6..9ab74885 100644 --- a/src/views/base/statistics/StatisticsTransactionPageBase.ts +++ b/src/views/base/statistics/StatisticsTransactionPageBase.ts @@ -30,7 +30,7 @@ export function useStatisticsTransactionPageBase() { getAllStatisticsSortingTypes, getAllStatisticsDateAggregationTypes, formatUnixTimeToLongDateTime, - formatUnixTimeToLongYearMonth, + getCalendarLongYearMonthFromUnixTime, formatDateRange, formatAmountToLocalizedNumeralsWithCurrency } = useI18n(); @@ -76,7 +76,7 @@ export function useStatisticsTransactionPageBase() { if (analysisType.value === StatisticsAnalysisType.CategoricalAnalysis) { return formatUnixTimeToLongDateTime(query.value.categoricalChartStartTime); } else if (analysisType.value === StatisticsAnalysisType.TrendAnalysis) { - return formatUnixTimeToLongYearMonth(getYearMonthFirstUnixTime(query.value.trendChartStartYearMonth)); + return getCalendarLongYearMonthFromUnixTime(getYearMonthFirstUnixTime(query.value.trendChartStartYearMonth)); } else { return ''; } @@ -86,7 +86,7 @@ export function useStatisticsTransactionPageBase() { if (analysisType.value === StatisticsAnalysisType.CategoricalAnalysis) { return formatUnixTimeToLongDateTime(query.value.categoricalChartEndTime); } else if (analysisType.value === StatisticsAnalysisType.TrendAnalysis) { - return formatUnixTimeToLongYearMonth(getYearMonthLastUnixTime(query.value.trendChartEndYearMonth)); + return getCalendarLongYearMonthFromUnixTime(getYearMonthLastUnixTime(query.value.trendChartEndYearMonth)); } else { return ''; } diff --git a/src/views/base/transactions/TransactionListPageBase.ts b/src/views/base/transactions/TransactionListPageBase.ts index a8235218..1eb6c9f5 100644 --- a/src/views/base/transactions/TransactionListPageBase.ts +++ b/src/views/base/transactions/TransactionListPageBase.ts @@ -78,7 +78,7 @@ export function useTransactionListPageBase() { getCurrentNumeralSystemType, formatUnixTimeToLongDateTime, formatUnixTimeToLongDate, - formatUnixTimeToLongYearMonth, + getCalendarLongYearMonthFromUnixTime, formatUnixTimeToShortTime, formatDateRange, formatAmountToLocalizedNumeralsWithCurrency @@ -287,7 +287,7 @@ export function useTransactionListPageBase() { } function getDisplayLongYearMonth(transactionMonthList: TransactionMonthList): string { - return formatUnixTimeToLongYearMonth(getYearMonthFirstUnixTime(transactionMonthList.yearDashMonth)); + return getCalendarLongYearMonthFromUnixTime(getYearMonthFirstUnixTime(transactionMonthList.yearDashMonth)); } function getDisplayTimezone(transaction: Transaction): string { diff --git a/src/views/desktop/overview/cards/MonthlyIncomeAndExpenseCard.vue b/src/views/desktop/overview/cards/MonthlyIncomeAndExpenseCard.vue index 4697e2d0..f0d09d46 100644 --- a/src/views/desktop/overview/cards/MonthlyIncomeAndExpenseCard.vue +++ b/src/views/desktop/overview/cards/MonthlyIncomeAndExpenseCard.vue @@ -60,7 +60,12 @@ const emit = defineEmits<{ (e: 'click', event: MonthlyIncomeAndExpenseCardClickEvent): void; }>(); -const { tt, getCurrentLanguageTextDirection, formatUnixTimeToShortMonth, formatAmountToLocalizedNumeralsWithCurrency } = useI18n(); +const { + tt, + getCurrentLanguageTextDirection, + getCalendarShortMonthFromUnixTime, + formatAmountToLocalizedNumeralsWithCurrency +} = useI18n(); const settingsStore = useSettingsStore(); const userStore = useUserStore(); @@ -96,7 +101,7 @@ const chartOptions = computed(() => { if (props.data) { for (let i = 0; i < props.data.length; i++) { const item = props.data[i]; - const monthShortName = formatUnixTimeToShortMonth(item.monthStartTime); + const monthShortName = getCalendarShortMonthFromUnixTime(item.monthStartTime); monthNames.push(monthShortName); incomeAmounts.push(item.incomeAmount); diff --git a/src/views/mobile/settings/TextSizeSettingsPage.vue b/src/views/mobile/settings/TextSizeSettingsPage.vue index 78da649b..22b652c8 100644 --- a/src/views/mobile/settings/TextSizeSettingsPage.vue +++ b/src/views/mobile/settings/TextSizeSettingsPage.vue @@ -136,9 +136,9 @@ const { tt, getCurrentLanguageTextDirection, getWeekdayShortName, - formatUnixTimeToLongYearMonth, + getCalendarLongYearMonthFromUnixTime, formatUnixTimeToShortTime, - formatUnixTimeToDayOfMonth, + getCalendarDayOfMonthFromUnixTime, formatAmountToLocalizedNumeralsWithCurrency } = useI18n(); @@ -149,8 +149,8 @@ const fontSize = ref(settingsStore.appSettings.fontSize); const textDirection = computed(() => getCurrentLanguageTextDirection()); const fontSizePreviewClassName = computed(() => getFontSizePreviewClassName(fontSize.value)); -const currentLongYearMonth = computed(() => formatUnixTimeToLongYearMonth(currentUnixTime.value)); -const currentDayOfMonth = computed(() => formatUnixTimeToDayOfMonth(currentUnixTime.value)); +const currentLongYearMonth = computed(() => getCalendarLongYearMonthFromUnixTime(currentUnixTime.value)); +const currentDayOfMonth = computed(() => getCalendarDayOfMonthFromUnixTime(currentUnixTime.value)); const currentDayOfWeek = computed(() => getWeekdayShortName(parseDateTimeFromUnixTime(currentUnixTime.value).getWeekDay())); const currentShortTime = computed(() => formatUnixTimeToShortTime(currentUnixTime.value)); diff --git a/src/views/mobile/transactions/ListPage.vue b/src/views/mobile/transactions/ListPage.vue index bbf2e711..94598464 100644 --- a/src/views/mobile/transactions/ListPage.vue +++ b/src/views/mobile/transactions/ListPage.vue @@ -202,7 +202,7 @@