code refactor

This commit is contained in:
MaysWind
2025-09-09 00:01:15 +08:00
parent 642e51bc0c
commit d4603a1892
21 changed files with 189 additions and 159 deletions
@@ -52,11 +52,11 @@ export interface CommonAccountBalanceTrendsChartProps {
export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTrendsChartProps) { export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTrendsChartProps) {
const { const {
getCalendarShortYearFromUnixTime, formatUnixTimeToShortDate,
getCalendarShortYearMonthFromUnixTime, formatUnixTimeToGregorianLikeShortYear,
getCalendarYearQuarterFromUnixTime, formatUnixTimeToGregorianLikeShortYearMonth,
getCalendarFiscalYearFromUnixTime, formatUnixTimeToGregorianLikeYearQuarter,
formatUnixTimeToShortDate formatUnixTimeToGregorianLikeFiscalYear
} = useI18n(); } = useI18n();
const dataDateRange = computed<AccountBalanceUnixTimeAndBalanceRange | null>(() => { const dataDateRange = computed<AccountBalanceUnixTimeAndBalanceRange | null>(() => {
@@ -156,13 +156,13 @@ export function useAccountBalanceTrendsChartBase(props: CommonAccountBalanceTren
let displayDate = ''; let displayDate = '';
if (props.dateAggregationType === ChartDateAggregationType.Year.type) { if (props.dateAggregationType === ChartDateAggregationType.Year.type) {
displayDate = getCalendarShortYearFromUnixTime(dateRange.minUnixTime); displayDate = formatUnixTimeToGregorianLikeShortYear(dateRange.minUnixTime);
} else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type) { } else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type) {
displayDate = getCalendarFiscalYearFromUnixTime(dateRange.minUnixTime); displayDate = formatUnixTimeToGregorianLikeFiscalYear(dateRange.minUnixTime);
} else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type) { } else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type) {
displayDate = getCalendarYearQuarterFromUnixTime(dateRange.minUnixTime); displayDate = formatUnixTimeToGregorianLikeYearQuarter(dateRange.minUnixTime);
} else if (props.dateAggregationType === ChartDateAggregationType.Month.type) { } else if (props.dateAggregationType === ChartDateAggregationType.Month.type) {
displayDate = getCalendarShortYearMonthFromUnixTime(dateRange.minUnixTime); displayDate = formatUnixTimeToGregorianLikeShortYearMonth(dateRange.minUnixTime);
} else { } else {
displayDate = formatUnixTimeToShortDate(dateRange.minUnixTime); displayDate = formatUnixTimeToShortDate(dateRange.minUnixTime);
} }
@@ -37,7 +37,7 @@ function getFiscalYearStartFromProps(props: CommonFiscalYearStartSelectionProps)
} }
export function useFiscalYearStartSelectionBase(props: CommonFiscalYearStartSelectionProps) { export function useFiscalYearStartSelectionBase(props: CommonFiscalYearStartSelectionProps) {
const { getCalendarLongMonthDayFromGregorianCalendarTextualMonthDay } = useI18n(); const { formatGregorianTextualMonthDayToGregorianLikeLongMonthDay } = useI18n();
const disabledDates = (date: Date) => { const disabledDates = (date: Date) => {
// Disable February 29 (leap day) // Disable February 29 (leap day)
@@ -71,7 +71,7 @@ export function useFiscalYearStartSelectionBase(props: CommonFiscalYearStartSele
fiscalYearStart = FiscalYearStart.Default; fiscalYearStart = FiscalYearStart.Default;
} }
return getCalendarLongMonthDayFromGregorianCalendarTextualMonthDay(fiscalYearStart.toMonthDashDayString()); return formatGregorianTextualMonthDayToGregorianLikeLongMonthDay(fiscalYearStart.toMonthDashDayString());
}); });
const allowedMinDate = computed<Date>(() => getLocalDatetimeFromUnixTime(getThisYearFirstUnixTime())); const allowedMinDate = computed<Date>(() => getLocalDatetimeFromUnixTime(getThisYearFirstUnixTime()));
@@ -49,7 +49,7 @@ function getMonthRangeFromProps(props: CommonMonthRangeSelectionProps): { minDat
} }
export function useMonthRangeSelectionBase(props: CommonMonthRangeSelectionProps) { export function useMonthRangeSelectionBase(props: CommonMonthRangeSelectionProps) {
const { getCalendarLongYearMonthFromUnixTime } = useI18n(); const { formatUnixTimeToGregorianLikeLongYearMonth } = useI18n();
const { minDate, maxDate } = getMonthRangeFromProps(props); const { minDate, maxDate } = getMonthRangeFromProps(props);
const dateRange = ref<Year0BasedMonth[]>([ const dateRange = ref<Year0BasedMonth[]>([
@@ -57,8 +57,8 @@ export function useMonthRangeSelectionBase(props: CommonMonthRangeSelectionProps
maxDate maxDate
]); ]);
const beginDateTime = computed<string>(() => getCalendarLongYearMonthFromUnixTime(getYearMonthFirstUnixTime(dateRange.value[0]))); const beginDateTime = computed<string>(() => formatUnixTimeToGregorianLikeLongYearMonth(getYearMonthFirstUnixTime(dateRange.value[0])));
const endDateTime = computed<string>(() => getCalendarLongYearMonthFromUnixTime(getYearMonthLastUnixTime(dateRange.value[1]))); const endDateTime = computed<string>(() => formatUnixTimeToGregorianLikeLongYearMonth(getYearMonthLastUnixTime(dateRange.value[1])));
function getFinalMonthRange(): { minYearMonth: TextualYearMonth | '', maxYearMonth: TextualYearMonth | '' } | null { function getFinalMonthRange(): { minYearMonth: TextualYearMonth | '', maxYearMonth: TextualYearMonth | '' } | null {
if (!dateRange.value[0] || !dateRange.value[1]) { if (!dateRange.value[0] || !dateRange.value[1]) {
+8 -8
View File
@@ -88,9 +88,9 @@ const {
getCurrentCalendarDisplayType, getCurrentCalendarDisplayType,
isLongDateMonthAfterYear, isLongDateMonthAfterYear,
isLongTime24HourFormat, isLongTime24HourFormat,
getCalendarShortYearFromUnixTime, getCalendarDisplayShortYearFromUnixTime,
getCalendarShortMonthFromUnixTime, getCalendarDisplayShortMonthFromUnixTime,
getCalendarDayOfMonthFromUnixTime, getCalendarDisplayDayOfMonthFromUnixTime,
getCalendarAlternateDate getCalendarAlternateDate
} = useI18n(); } = useI18n();
@@ -130,21 +130,21 @@ function switchView(viewType: MenuView): void {
} }
function getDisplayYear(year: number): string { function getDisplayYear(year: number): string {
return getCalendarShortYearFromUnixTime(getYearMonthDayDateTime(year, 1, 1).getUnixTime()); return getCalendarDisplayShortYearFromUnixTime(getYearMonthDayDateTime(year, 1, 1).getUnixTime());
} }
function getDisplayMonth(month: number): string { function getDisplayMonth(month: number): string {
if (isArray(dateTime.value)) { if (isArray(dateTime.value)) {
return getCalendarShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value[0].getFullYear(), month + 1, 1).getUnixTime()); return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value[0].getFullYear(), month + 1, 1).getUnixTime());
} else if (dateTime.value) { } else if (dateTime.value) {
return getCalendarShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value.getFullYear(), month + 1, 1).getUnixTime()); return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value.getFullYear(), month + 1, 1).getUnixTime());
} else { } else {
return getCalendarShortMonthFromUnixTime(getYearMonthDayDateTime(new Date().getFullYear(), month + 1, 1).getUnixTime()); return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(new Date().getFullYear(), month + 1, 1).getUnixTime());
} }
} }
function getDisplayDay(date: Date): string { function getDisplayDay(date: Date): string {
return getCalendarDayOfMonthFromUnixTime(getYearMonthDayDateTime(date.getFullYear(), date.getMonth() + 1, date.getDate()).getUnixTime()); return getCalendarDisplayDayOfMonthFromUnixTime(getYearMonthDayDateTime(date.getFullYear(), date.getMonth() + 1, date.getDate()).getUnixTime());
} }
defineExpose({ defineExpose({
+5 -5
View File
@@ -55,8 +55,8 @@ const emit = defineEmits<{
const { const {
isLongDateMonthAfterYear, isLongDateMonthAfterYear,
getCalendarShortYearFromUnixTime, getCalendarDisplayShortYearFromUnixTime,
getCalendarShortMonthFromUnixTime getCalendarDisplayShortMonthFromUnixTime
} = useI18n(); } = useI18n();
const yearRange = getAllowedYearRange(); const yearRange = getAllowedYearRange();
@@ -97,14 +97,14 @@ function getYear0BasedMonthFromMonthSelectionValue(value: MonthSelectionValue):
} }
function getDisplayYear(year: number): string { function getDisplayYear(year: number): string {
return getCalendarShortYearFromUnixTime(getYearMonthDayDateTime(year, 1, 1).getUnixTime()); return getCalendarDisplayShortYearFromUnixTime(getYearMonthDayDateTime(year, 1, 1).getUnixTime());
} }
function getDisplayMonth(month: number): string { function getDisplayMonth(month: number): string {
if (isArray(dateTime.value)) { if (isArray(dateTime.value)) {
return getCalendarShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value[0].year, month + 1, 1).getUnixTime()); return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value[0].year, month + 1, 1).getUnixTime());
} else { } else {
return getCalendarShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value.year, month + 1, 1).getUnixTime()); return getCalendarDisplayShortMonthFromUnixTime(getYearMonthDayDateTime(dateTime.value.year, month + 1, 1).getUnixTime());
} }
} }
</script> </script>
@@ -69,7 +69,7 @@ const emit = defineEmits<{
const { const {
getAllLongWeekdayNames, getAllLongWeekdayNames,
getAllShortWeekdayNames, getAllShortWeekdayNames,
getCalendarDayOfMonthFromUnixTime, getCalendarDisplayDayOfMonthFromUnixTime,
getCalendarAlternateDates, getCalendarAlternateDates,
formatAmountToLocalizedNumeralsWithCurrency formatAmountToLocalizedNumeralsWithCurrency
} = useI18n(); } = useI18n();
@@ -117,7 +117,7 @@ function getDisplayMonthTotalAmount(amount: number, currency: string | false, sy
} }
function getDisplayDay(date: Date): string { function getDisplayDay(date: Date): string {
return getCalendarDayOfMonthFromUnixTime(getYearMonthDayDateTime(date.getFullYear(), date.getMonth() + 1, date.getDate()).getUnixTime()); return getCalendarDisplayDayOfMonthFromUnixTime(getYearMonthDayDateTime(date.getFullYear(), date.getMonth() + 1, date.getDate()).getUnixTime());
} }
</script> </script>
+2 -2
View File
@@ -51,7 +51,7 @@ const emit = defineEmits<{
}>(); }>();
const theme = useTheme(); const theme = useTheme();
const { tt, formatGregorianCalendarYearDashMonthDashDayToLongDate } = useI18n(); const { tt, formatGregorianTextualYearMonthDayToLongDate } = useI18n();
const dateTime = computed<Date | null>({ const dateTime = computed<Date | null>({
get: () => props.modelValue ? getLocalDateFromYearDashMonthDashDay(props.modelValue) : null, get: () => props.modelValue ? getLocalDateFromYearDashMonthDashDay(props.modelValue) : null,
@@ -62,7 +62,7 @@ const isDarkMode = computed<boolean>(() => theme.global.name.value === ThemeType
const displayTime = computed<string>({ const displayTime = computed<string>({
get: () => { get: () => {
if (props.modelValue) { if (props.modelValue) {
return formatGregorianCalendarYearDashMonthDashDayToLongDate(props.modelValue); return formatGregorianTextualYearMonthDayToLongDate(props.modelValue);
} else if (props.noDataText) { } else if (props.noDataText) {
return props.noDataText; return props.noDataText;
} else { } else {
@@ -80,10 +80,10 @@ const theme = useTheme();
const { const {
tt, tt,
getCurrentLanguageTextDirection, getCurrentLanguageTextDirection,
getCalendarShortYearFromUnixTime, formatUnixTimeToGregorianLikeShortYear,
getCalendarShortYearMonthFromUnixTime, formatUnixTimeToGregorianLikeShortYearMonth,
getCalendarYearQuarterFromYearQuarter, formatYearQuarterToGregorianLikeYearQuarter,
getCalendarFiscalYearFromUnixTime, formatUnixTimeToGregorianLikeFiscalYear,
formatAmountToWesternArabicNumeralsWithoutDigitGrouping, formatAmountToWesternArabicNumeralsWithoutDigitGrouping,
formatAmountToLocalizedNumeralsWithCurrency formatAmountToLocalizedNumeralsWithCurrency
} = useI18n(); } = useI18n();
@@ -139,13 +139,13 @@ const allDisplayDateRanges = computed<string[]>(() => {
const dateRange = allDateRanges.value[i]; const dateRange = allDateRanges.value[i];
if (props.dateAggregationType === ChartDateAggregationType.Year.type) { if (props.dateAggregationType === ChartDateAggregationType.Year.type) {
allDisplayDateRanges.push(getCalendarShortYearFromUnixTime(dateRange.minUnixTime)); allDisplayDateRanges.push(formatUnixTimeToGregorianLikeShortYear(dateRange.minUnixTime));
} else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type && 'year' in dateRange) { } else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type && 'year' in dateRange) {
allDisplayDateRanges.push(getCalendarFiscalYearFromUnixTime(dateRange.minUnixTime)); allDisplayDateRanges.push(formatUnixTimeToGregorianLikeFiscalYear(dateRange.minUnixTime));
} else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type && 'quarter' in dateRange) { } else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type && 'quarter' in dateRange) {
allDisplayDateRanges.push(getCalendarYearQuarterFromYearQuarter(dateRange.year, dateRange.quarter)); allDisplayDateRanges.push(formatYearQuarterToGregorianLikeYearQuarter(dateRange.year, dateRange.quarter));
} else { // if (props.dateAggregationType === ChartDateAggregationType.Month.type) { } else { // if (props.dateAggregationType === ChartDateAggregationType.Month.type) {
allDisplayDateRanges.push(getCalendarShortYearMonthFromUnixTime(dateRange.minUnixTime)); allDisplayDateRanges.push(formatUnixTimeToGregorianLikeShortYearMonth(dateRange.minUnixTime));
} }
} }
@@ -156,10 +156,10 @@ const emit = defineEmits<{
const { const {
tt, tt,
getCalendarShortYearFromUnixTime, formatUnixTimeToGregorianLikeShortYear,
getCalendarShortYearMonthFromUnixTime, formatUnixTimeToGregorianLikeShortYearMonth,
getCalendarYearQuarterFromYearQuarter, formatYearQuarterToGregorianLikeYearQuarter,
getCalendarFiscalYearFromUnixTime, formatUnixTimeToGregorianLikeFiscalYear,
formatAmountToLocalizedNumeralsWithCurrency formatAmountToLocalizedNumeralsWithCurrency
} = useI18n(); } = useI18n();
@@ -250,13 +250,13 @@ const allDisplayDataItems = computed<MonthlyTrendsBarChartData>(() => {
let displayDateRange = ''; let displayDateRange = '';
if (props.dateAggregationType === ChartDateAggregationType.Year.type) { if (props.dateAggregationType === ChartDateAggregationType.Year.type) {
displayDateRange = getCalendarShortYearFromUnixTime(dateRange.minUnixTime); displayDateRange = formatUnixTimeToGregorianLikeShortYear(dateRange.minUnixTime);
} else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type) { } else if (props.dateAggregationType === ChartDateAggregationType.FiscalYear.type) {
displayDateRange = getCalendarFiscalYearFromUnixTime(dateRange.minUnixTime); displayDateRange = formatUnixTimeToGregorianLikeFiscalYear(dateRange.minUnixTime);
} else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type && 'quarter' in dateRange) { } else if (props.dateAggregationType === ChartDateAggregationType.Quarter.type && 'quarter' in dateRange) {
displayDateRange = getCalendarYearQuarterFromYearQuarter(dateRange.year, dateRange.quarter); displayDateRange = formatYearQuarterToGregorianLikeYearQuarter(dateRange.year, dateRange.quarter);
} else { // if (props.dateAggregationType === ChartDateAggregationType.Month.type) { } else { // if (props.dateAggregationType === ChartDateAggregationType.Month.type) {
displayDateRange = getCalendarShortYearMonthFromUnixTime(dateRange.minUnixTime); displayDateRange = formatUnixTimeToGregorianLikeShortYearMonth(dateRange.minUnixTime);
} }
const dataItems = allDateRangeItemsMap[dateRangeKey] || []; const dataItems = allDateRangeItemsMap[dateRangeKey] || [];
+1
View File
@@ -51,6 +51,7 @@ export interface DateTimeLocaleData {
} }
export type TextualYearMonth = `${number}-${number}`; export type TextualYearMonth = `${number}-${number}`;
export type TextualMonthDay = `${number}-${number}`;
export type TextualYearMonthDay = `${number}-${number}-${number}`; export type TextualYearMonthDay = `${number}-${number}-${number}`;
export interface YearQuarter { export interface YearQuarter {
+2 -1
View File
@@ -11,6 +11,7 @@ import {
type DateTime, type DateTime,
type DateTimeFormatOptions, type DateTimeFormatOptions,
type TextualYearMonth, type TextualYearMonth,
type TextualMonthDay,
type TextualYearMonthDay, type TextualYearMonthDay,
type YearUnixTime, type YearUnixTime,
type YearQuarter, type YearQuarter,
@@ -565,7 +566,7 @@ export function formatGregorianCalendarYearDashMonthDashDay(date: TextualYearMon
return MomentDateTime.of(moment(date, 'YYYY-MM-DD')).format(format, options); return MomentDateTime.of(moment(date, 'YYYY-MM-DD')).format(format, options);
} }
export function formatGregorianCalendarMonthDashDay(monthDay: TextualYearMonth, format: string, options: DateTimeFormatOptions): string { export function formatGregorianCalendarMonthDashDay(monthDay: TextualMonthDay, format: string, options: DateTimeFormatOptions): string {
return MomentDateTime.of(moment(monthDay, 'MM-DD')).format(format, options); return MomentDateTime.of(moment(monthDay, 'MM-DD')).format(format, options);
} }
+110 -82
View File
@@ -37,7 +37,7 @@ import {
type DateTime, type DateTime,
type DateTimeFormatOptions, type DateTimeFormatOptions,
type DateTimeLocaleData, type DateTimeLocaleData,
type TextualYearMonth, type TextualMonthDay,
type TextualYearMonthDay, type TextualYearMonthDay,
type Year1BasedMonth, type Year1BasedMonth,
type YearMonthDay, type YearMonthDay,
@@ -778,15 +778,38 @@ export function useI18n() {
return ''; return '';
} }
function formatTimeRangeToFiscalYearFormat(format: FiscalYearFormat, timeRange: FiscalYearUnixTime | UnixTimeRange, numeralSystem?: NumeralSystem, calendarType?: CalendarType): string { function isGregorianLikeCalendarType(calendarType: CalendarType): boolean {
return calendarType === CalendarType.Gregorian || calendarType === CalendarType.Buddhist;
}
function getGregorianLikeCalendarType(): CalendarType {
const currentDateDisplayType = getCurrentDateDisplayType();
if (isGregorianLikeCalendarType(currentDateDisplayType.calendarType)) {
return currentDateDisplayType.calendarType;
}
return CalendarType.Gregorian;
}
function formatYearQuarter(year: string, quarter: number): string {
if (1 <= quarter && quarter <= 4) {
return t('format.yearQuarter.q' + quarter, {
year: year,
quarter: quarter
});
} else {
return '';
}
}
function formatTimeRangeToGregorianLikeFiscalYearFormat(format: FiscalYearFormat, timeRange: FiscalYearUnixTime | UnixTimeRange, numeralSystem?: NumeralSystem, calendarType?: CalendarType): string {
if (!format) { if (!format) {
format = FiscalYearFormat.Default; format = FiscalYearFormat.Default;
} }
const currentCalendarDisplayType = getCurrentCalendarDisplayType(); if (!isDefined(calendarType) || !isGregorianLikeCalendarType(calendarType)) {
calendarType = getGregorianLikeCalendarType();
if (!isDefined(calendarType)) {
calendarType = currentCalendarDisplayType.primaryCalendarType;
} }
const dateTimeFormatOptions = getDateTimeFormatOptions({ const dateTimeFormatOptions = getDateTimeFormatOptions({
@@ -1241,7 +1264,7 @@ export function useI18n() {
ret.push({ ret.push({
type: LANGUAGE_DEFAULT_FISCAL_YEAR_FORMAT_VALUE, type: LANGUAGE_DEFAULT_FISCAL_YEAR_FORMAT_VALUE,
displayName: `${t('Language Default')} (${formatTimeRangeToFiscalYearFormat(defaultFiscalYearFormat, currentFiscalYearRange, numeralSystem, calendarType)})` displayName: `${t('Language Default')} (${formatTimeRangeToGregorianLikeFiscalYearFormat(defaultFiscalYearFormat, currentFiscalYearRange, numeralSystem, calendarType)})`
}); });
const allFiscalYearFormats = FiscalYearFormat.values(); const allFiscalYearFormats = FiscalYearFormat.values();
@@ -1251,7 +1274,7 @@ export function useI18n() {
ret.push({ ret.push({
type: fiscalYearFormat.type, type: fiscalYearFormat.type,
displayName: formatTimeRangeToFiscalYearFormat(fiscalYearFormat, currentFiscalYearRange, numeralSystem, calendarType), displayName: formatTimeRangeToGregorianLikeFiscalYearFormat(fiscalYearFormat, currentFiscalYearRange, numeralSystem, calendarType),
}); });
} }
@@ -1807,29 +1830,58 @@ export function useI18n() {
return getLocalizedLongTimeFormat().indexOf('ss') >= 0; return getLocalizedLongTimeFormat().indexOf('ss') >= 0;
} }
function getCalendarLongMonthDayFromGregorianCalendarTextualMonthDay(monthDay: TextualYearMonth): string { function formatGregorianTextualMonthDayToGregorianLikeLongMonthDay(monthDay: TextualMonthDay): string {
const currentCalendarDisplayType = getCurrentCalendarDisplayType(); const gregorianLikeCalendarType = getGregorianLikeCalendarType();
return formatGregorianCalendarMonthDashDay(monthDay, getLocalizedLongMonthDayFormat(), getDateTimeFormatOptions({ calendarType: currentCalendarDisplayType.primaryCalendarType })); return formatGregorianCalendarMonthDashDay(monthDay, getLocalizedLongMonthDayFormat(), getDateTimeFormatOptions({ calendarType: gregorianLikeCalendarType }));
} }
function getCalendarYearQuarterFromUnixTime(unixTime: number): string { function formatUnixTimeToGregorianLikeYearQuarter(unixTime: number): string {
const currentCalendarDisplayType = getCurrentCalendarDisplayType(); const gregorianLikeCalendarType = getGregorianLikeCalendarType();
const dateTimeFormatOptions = getDateTimeFormatOptions({ calendarType: currentCalendarDisplayType.primaryCalendarType }); const dateTimeFormatOptions = getDateTimeFormatOptions({ calendarType: gregorianLikeCalendarType });
const date = parseDateTimeFromUnixTime(unixTime); const date = parseDateTimeFromUnixTime(unixTime);
const year = date.getLocalizedCalendarYear(dateTimeFormatOptions); const year = date.getLocalizedCalendarYear(dateTimeFormatOptions);
const quarter = date.getLocalizedCalendarQuarter(dateTimeFormatOptions); const quarter = date.getLocalizedCalendarQuarter(dateTimeFormatOptions);
return getCalendarYearQuarterFromYearQuarter(year, quarter); return formatYearQuarter(year, quarter);
} }
function getCalendarYearQuarterFromYearQuarter(year: number | string, quarter: number): string { function formatYearQuarterToGregorianLikeYearQuarter(year: number, quarter: number): string {
if (1 <= quarter && quarter <= 4) { const gregorianLikeCalendarType = getGregorianLikeCalendarType();
return t('format.yearQuarter.q' + quarter, { const dateTimeFormatOptions = getDateTimeFormatOptions({ calendarType: gregorianLikeCalendarType });
year: year, const date = getYearMonthDayDateTime(year, 1, 1);
quarter: quarter const textualYear = date.getLocalizedCalendarYear(dateTimeFormatOptions);
}); return formatYearQuarter(textualYear, quarter);
} else { }
return '';
function formatUnixTimeToGregorianLikeFiscalYear(unixTime: number): string {
let fiscalYearFormat = FiscalYearFormat.valueOf(getCurrentFiscalYearFormatType());
if (!fiscalYearFormat) {
fiscalYearFormat = FiscalYearFormat.Default;
} }
const timeRange = getFiscalYearTimeRangeFromUnixTime(unixTime, userStore.currentUserFiscalYearStart);
return formatTimeRangeToGregorianLikeFiscalYearFormat(fiscalYearFormat, timeRange);
}
function formatGregorianYearToGregorianLikeFiscalYear(year: number) {
let fiscalYearFormat = FiscalYearFormat.valueOf(getCurrentFiscalYearFormatType());
if (!fiscalYearFormat) {
fiscalYearFormat = FiscalYearFormat.Default;
}
const timeRange = getFiscalYearTimeRangeFromYear(year, userStore.currentUserFiscalYearStart);
return formatTimeRangeToGregorianLikeFiscalYearFormat(fiscalYearFormat, timeRange);
}
function formatFiscalYearStartToGregorianLikeLongMonth(fiscalYearStartValue: number) {
let fiscalYearStart = FiscalYearStart.valueOf(fiscalYearStartValue);
if (!fiscalYearStart) {
fiscalYearStart = FiscalYearStart.Default;
}
return formatGregorianTextualMonthDayToGregorianLikeLongMonthDay(fiscalYearStart.toMonthDashDayString());
} }
function formatDateRange(dateType: number, startTime: number, endTime: number): string { function formatDateRange(dateType: number, startTime: number, endTime: number): string {
@@ -1838,8 +1890,9 @@ export function useI18n() {
} }
const allDateRanges = DateRange.values(); const allDateRanges = DateRange.values();
const currentCalendarDisplayType = getCurrentCalendarDisplayType(); const gregorianLikeCalendarType = getGregorianLikeCalendarType();
const dateTimeFormatOptions = getDateTimeFormatOptions({ calendarType: currentCalendarDisplayType.primaryCalendarType }); const dateTimeFormatOptions = getDateTimeFormatOptions();
const gregorianLikeDateTimeFormatOptions = getDateTimeFormatOptions({ calendarType: gregorianLikeCalendarType });
for (let i = 0; i < allDateRanges.length; i++) { for (let i = 0; i < allDateRanges.length; i++) {
const dateRange = allDateRanges[i]; const dateRange = allDateRanges[i];
@@ -1851,22 +1904,22 @@ export function useI18n() {
if (isDateRangeMatchFullYears(startTime, endTime)) { if (isDateRangeMatchFullYears(startTime, endTime)) {
const format = getLocalizedShortYearFormat(); const format = getLocalizedShortYearFormat();
const displayStartTime = formatUnixTime(startTime, format, dateTimeFormatOptions); const displayStartTime = formatUnixTime(startTime, format, gregorianLikeDateTimeFormatOptions);
const displayEndTime = formatUnixTime(endTime, format, dateTimeFormatOptions); const displayEndTime = formatUnixTime(endTime, format, gregorianLikeDateTimeFormatOptions);
return displayStartTime !== displayEndTime ? `${displayStartTime} ~ ${displayEndTime}` : displayStartTime; return displayStartTime !== displayEndTime ? `${displayStartTime} ~ ${displayEndTime}` : displayStartTime;
} }
if (isDateRangeMatchFullMonths(startTime, endTime)) { if (isDateRangeMatchFullMonths(startTime, endTime)) {
const format = getLocalizedShortYearMonthFormat(); const format = getLocalizedShortYearMonthFormat();
const displayStartTime = formatUnixTime(startTime, format, dateTimeFormatOptions); const displayStartTime = formatUnixTime(startTime, format, gregorianLikeDateTimeFormatOptions);
const displayEndTime = formatUnixTime(endTime, format, dateTimeFormatOptions); const displayEndTime = formatUnixTime(endTime, format, gregorianLikeDateTimeFormatOptions);
return displayStartTime !== displayEndTime ? `${displayStartTime} ~ ${displayEndTime}` : displayStartTime; return displayStartTime !== displayEndTime ? `${displayStartTime} ~ ${displayEndTime}` : displayStartTime;
} }
const startTimeYear = parseDateTimeFromUnixTime(startTime).getLocalizedCalendarYear(dateTimeFormatOptions); const startTimeYear = parseDateTimeFromUnixTime(startTime).getLocalizedCalendarYear(gregorianLikeDateTimeFormatOptions);
const endTimeYear = parseDateTimeFromUnixTime(endTime).getLocalizedCalendarYear(dateTimeFormatOptions); const endTimeYear = parseDateTimeFromUnixTime(endTime).getLocalizedCalendarYear(gregorianLikeDateTimeFormatOptions);
const format = getLocalizedShortDateFormat(); const format = getLocalizedShortDateFormat();
const displayStartTime = formatUnixTime(startTime, format, dateTimeFormatOptions); const displayStartTime = formatUnixTime(startTime, format, dateTimeFormatOptions);
@@ -1875,45 +1928,13 @@ export function useI18n() {
if (displayStartTime === displayEndTime) { if (displayStartTime === displayEndTime) {
return displayStartTime; return displayStartTime;
} else if (startTimeYear === endTimeYear) { } else if (startTimeYear === endTimeYear) {
const displayShortEndTime = formatUnixTime(endTime, getLocalizedShortMonthDayFormat(), dateTimeFormatOptions); const displayShortEndTime = formatUnixTime(endTime, getLocalizedShortMonthDayFormat(), gregorianLikeDateTimeFormatOptions);
return `${displayStartTime} ~ ${displayShortEndTime}`; return `${displayStartTime} ~ ${displayShortEndTime}`;
} }
return `${displayStartTime} ~ ${displayEndTime}`; return `${displayStartTime} ~ ${displayEndTime}`;
} }
function getCalendarFiscalYearFromUnixTime(unixTime: number): string {
let fiscalYearFormat = FiscalYearFormat.valueOf(getCurrentFiscalYearFormatType());
if (!fiscalYearFormat) {
fiscalYearFormat = FiscalYearFormat.Default;
}
const timeRange = getFiscalYearTimeRangeFromUnixTime(unixTime, userStore.currentUserFiscalYearStart);
return formatTimeRangeToFiscalYearFormat(fiscalYearFormat, timeRange);
}
function getCalendarFiscalYearGregorianCalendarYear(year: number) {
let fiscalYearFormat = FiscalYearFormat.valueOf(getCurrentFiscalYearFormatType());
if (!fiscalYearFormat) {
fiscalYearFormat = FiscalYearFormat.Default;
}
const timeRange = getFiscalYearTimeRangeFromYear(year, userStore.currentUserFiscalYearStart);
return formatTimeRangeToFiscalYearFormat(fiscalYearFormat, timeRange);
}
function getCalendarLongMonthDayFromFiscalYearStart(fiscalYearStartValue: number) {
let fiscalYearStart = FiscalYearStart.valueOf(fiscalYearStartValue);
if (!fiscalYearStart) {
fiscalYearStart = FiscalYearStart.Default;
}
return getCalendarLongMonthDayFromGregorianCalendarTextualMonthDay(fiscalYearStart.toMonthDashDayString());
}
function getTimezoneDifferenceDisplayText(utcOffset: number): string { function getTimezoneDifferenceDisplayText(utcOffset: number): string {
const numeralSystem = getCurrentNumeralSystemType(); const numeralSystem = getCurrentNumeralSystemType();
const defaultTimezoneOffset = getTimezoneOffsetMinutes(); const defaultTimezoneOffset = getTimezoneOffsetMinutes();
@@ -2400,34 +2421,41 @@ export function useI18n() {
isLongTimeHourTwoDigits, isLongTimeHourTwoDigits,
isLongTimeMinuteTwoDigits, isLongTimeMinuteTwoDigits,
isLongTimeSecondTwoDigits, isLongTimeSecondTwoDigits,
// format functions // format date time (by calendar display type) functions
getCalendarLongYearFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedLongYearFormat(), getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset), getCalendarDisplayShortYearFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortYearFormat(), getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset),
getCalendarShortYearFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortYearFormat(), getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset), getCalendarDisplayShortMonthFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, 'MMM', getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset),
getCalendarLongMonthFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, 'MMMM', getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset), getCalendarDisplayDayOfMonthFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortDayFormat(), getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset),
getCalendarShortMonthFromUnixTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, 'MMM', getDateTimeFormatOptions({ calendarType: getCurrentCalendarDisplayType().primaryCalendarType }), utcOffset, currentUtcOffset), // format date time (by date display type) functions
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), 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), 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), 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), formatUnixTimeToShortDate: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortDateFormat(), 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), 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), formatUnixTimeToShortTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortTimeFormat(), getDateTimeFormatOptions(), utcOffset, currentUtcOffset),
formatGregorianCalendarYearDashMonthDashDayToLongDate: (date: TextualYearMonthDay) => formatGregorianCalendarYearDashMonthDashDay(date, getLocalizedLongDateFormat(), getDateTimeFormatOptions()), formatGregorianTextualYearMonthDayToLongDate: (date: TextualYearMonthDay) => formatGregorianCalendarYearDashMonthDashDay(date, getLocalizedLongDateFormat(), getDateTimeFormatOptions()),
// format date time (Gregorian calendar and Gregorian-like calendar) functions
formatUnixTimeToGregorianLikeLongYear: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedLongYearFormat(), getDateTimeFormatOptions({ calendarType: getGregorianLikeCalendarType() }), utcOffset, currentUtcOffset),
formatUnixTimeToGregorianLikeShortYear: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortYearFormat(), getDateTimeFormatOptions({ calendarType: getGregorianLikeCalendarType() }), utcOffset, currentUtcOffset),
formatUnixTimeToGregorianLikeLongYearMonth: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedLongYearMonthFormat(), getDateTimeFormatOptions({ calendarType: getGregorianLikeCalendarType() }), utcOffset, currentUtcOffset),
formatUnixTimeToGregorianLikeShortYearMonth: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, getLocalizedShortYearMonthFormat(), getDateTimeFormatOptions({ calendarType: getGregorianLikeCalendarType() }), utcOffset, currentUtcOffset),
formatUnixTimeToGregorianLikeLongMonth: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, 'MMMM', getDateTimeFormatOptions({ calendarType: getGregorianLikeCalendarType() }), utcOffset, currentUtcOffset),
formatUnixTimeToGregorianLikeShortMonth: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, 'MMM', getDateTimeFormatOptions({ calendarType: getGregorianLikeCalendarType() }), utcOffset, currentUtcOffset),
formatGregorianTextualMonthDayToGregorianLikeLongMonthDay,
formatUnixTimeToGregorianLikeYearQuarter,
formatYearQuarterToGregorianLikeYearQuarter,
formatUnixTimeToGregorianLikeFiscalYear,
formatGregorianYearToGregorianLikeFiscalYear,
formatFiscalYearStartToGregorianLikeLongMonth,
// format date time (Gregorian calendar) functions
formatUnixTimeToGregorianDefaultDateTime: (unixTime: number, utcOffset?: number, currentUtcOffset?: number) => formatUnixTime(unixTime, KnownDateTimeFormat.DefaultDateTime.format, getDateTimeFormatOptions({ numeralSystem: NumeralSystem.WesternArabicNumerals, calendarType: CalendarType.Gregorian }), utcOffset, currentUtcOffset),
// other format date time functions
formatDateRange, formatDateRange,
getTimezoneDifferenceDisplayText, getTimezoneDifferenceDisplayText,
getCalendarAlternateDates, getCalendarAlternateDates,
getCalendarAlternateDate, getCalendarAlternateDate,
// format amount/number functions
parseAmountFromLocalizedNumerals: (value: string) => getParsedAmountNumber(value), parseAmountFromLocalizedNumerals: (value: string) => getParsedAmountNumber(value),
parseAmountFromWesternArabicNumerals: (value: string) => getParsedAmountNumber(value, NumeralSystem.WesternArabicNumerals), parseAmountFromWesternArabicNumerals: (value: string) => getParsedAmountNumber(value, NumeralSystem.WesternArabicNumerals),
formatAmountToLocalizedNumerals: (value: number, currencyCode?: string) => getFormattedAmount(value, undefined, undefined, currencyCode), formatAmountToLocalizedNumerals: (value: number, currencyCode?: string) => getFormattedAmount(value, undefined, undefined, currencyCode),
+9 -9
View File
@@ -20,9 +20,9 @@ import type {
export function useHomePageBase() { export function useHomePageBase() {
const { const {
formatUnixTimeToLongDate, formatUnixTimeToLongDate,
getCalendarLongYearFromUnixTime, formatUnixTimeToLongMonthDay,
getCalendarLongMonthFromUnixTime, formatUnixTimeToGregorianLikeLongYear,
getCalendarLongMonthDayFromUnixTime, formatUnixTimeToGregorianLikeLongMonth,
formatAmountToLocalizedNumeralsWithCurrency formatAmountToLocalizedNumeralsWithCurrency
} = useI18n(); } = useI18n();
@@ -60,16 +60,16 @@ export function useHomePageBase() {
displayTime: formatUnixTimeToLongDate(overviewStore.transactionDataRange.today.startTime), displayTime: formatUnixTimeToLongDate(overviewStore.transactionDataRange.today.startTime),
}, },
thisWeek: { thisWeek: {
startTime: getCalendarLongMonthDayFromUnixTime(overviewStore.transactionDataRange.thisWeek.startTime), startTime: formatUnixTimeToLongMonthDay(overviewStore.transactionDataRange.thisWeek.startTime),
endTime: getCalendarLongMonthDayFromUnixTime(overviewStore.transactionDataRange.thisWeek.endTime) endTime: formatUnixTimeToLongMonthDay(overviewStore.transactionDataRange.thisWeek.endTime)
}, },
thisMonth: { thisMonth: {
displayTime: getCalendarLongMonthFromUnixTime(overviewStore.transactionDataRange.thisMonth.startTime), displayTime: formatUnixTimeToGregorianLikeLongMonth(overviewStore.transactionDataRange.thisMonth.startTime),
startTime: getCalendarLongMonthDayFromUnixTime(overviewStore.transactionDataRange.thisMonth.startTime), startTime: formatUnixTimeToLongMonthDay(overviewStore.transactionDataRange.thisMonth.startTime),
endTime: getCalendarLongMonthDayFromUnixTime(overviewStore.transactionDataRange.thisMonth.endTime) endTime: formatUnixTimeToLongMonthDay(overviewStore.transactionDataRange.thisMonth.endTime)
}, },
thisYear: { thisYear: {
displayTime: getCalendarLongYearFromUnixTime(overviewStore.transactionDataRange.thisYear.startTime) displayTime: formatUnixTimeToGregorianLikeLongYear(overviewStore.transactionDataRange.thisYear.startTime)
} }
}; };
}); });
@@ -31,10 +31,10 @@ export function useReconciliationStatementPageBase() {
tt, tt,
getAllAccountBalanceTrendChartTypes, getAllAccountBalanceTrendChartTypes,
getAllStatisticsDateAggregationTypesWithShortName, getAllStatisticsDateAggregationTypesWithShortName,
formatUnixTimeToDefaultDateTimeWithoutLocaleOptions,
formatUnixTimeToLongDateTime, formatUnixTimeToLongDateTime,
formatUnixTimeToLongDate, formatUnixTimeToLongDate,
formatUnixTimeToShortTime, formatUnixTimeToShortTime,
formatUnixTimeToGregorianDefaultDateTime,
formatAmountToWesternArabicNumeralsWithoutDigitGrouping, formatAmountToWesternArabicNumeralsWithoutDigitGrouping,
formatAmountToLocalizedNumeralsWithCurrency formatAmountToLocalizedNumeralsWithCurrency
} = useI18n(); } = useI18n();
@@ -241,7 +241,7 @@ export function useReconciliationStatementPageBase() {
} }
return [ return [
formatUnixTimeToDefaultDateTimeWithoutLocaleOptions(transactionTime), formatUnixTimeToGregorianDefaultDateTime(transactionTime),
type, type,
categoryName, categoryName,
displayAmount, displayAmount,
@@ -30,7 +30,7 @@ export function useStatisticsTransactionPageBase() {
getAllStatisticsSortingTypes, getAllStatisticsSortingTypes,
getAllStatisticsDateAggregationTypes, getAllStatisticsDateAggregationTypes,
formatUnixTimeToLongDateTime, formatUnixTimeToLongDateTime,
getCalendarLongYearMonthFromUnixTime, formatUnixTimeToGregorianLikeLongYearMonth,
formatDateRange, formatDateRange,
formatAmountToLocalizedNumeralsWithCurrency formatAmountToLocalizedNumeralsWithCurrency
} = useI18n(); } = useI18n();
@@ -76,7 +76,7 @@ export function useStatisticsTransactionPageBase() {
if (analysisType.value === StatisticsAnalysisType.CategoricalAnalysis) { if (analysisType.value === StatisticsAnalysisType.CategoricalAnalysis) {
return formatUnixTimeToLongDateTime(query.value.categoricalChartStartTime); return formatUnixTimeToLongDateTime(query.value.categoricalChartStartTime);
} else if (analysisType.value === StatisticsAnalysisType.TrendAnalysis) { } else if (analysisType.value === StatisticsAnalysisType.TrendAnalysis) {
return getCalendarLongYearMonthFromUnixTime(getYearMonthFirstUnixTime(query.value.trendChartStartYearMonth)); return formatUnixTimeToGregorianLikeLongYearMonth(getYearMonthFirstUnixTime(query.value.trendChartStartYearMonth));
} else { } else {
return ''; return '';
} }
@@ -86,7 +86,7 @@ export function useStatisticsTransactionPageBase() {
if (analysisType.value === StatisticsAnalysisType.CategoricalAnalysis) { if (analysisType.value === StatisticsAnalysisType.CategoricalAnalysis) {
return formatUnixTimeToLongDateTime(query.value.categoricalChartEndTime); return formatUnixTimeToLongDateTime(query.value.categoricalChartEndTime);
} else if (analysisType.value === StatisticsAnalysisType.TrendAnalysis) { } else if (analysisType.value === StatisticsAnalysisType.TrendAnalysis) {
return getCalendarLongYearMonthFromUnixTime(getYearMonthLastUnixTime(query.value.trendChartEndYearMonth)); return formatUnixTimeToGregorianLikeLongYearMonth(getYearMonthLastUnixTime(query.value.trendChartEndYearMonth));
} else { } else {
return ''; return '';
} }
@@ -78,8 +78,8 @@ export function useTransactionListPageBase() {
getCurrentNumeralSystemType, getCurrentNumeralSystemType,
formatUnixTimeToLongDateTime, formatUnixTimeToLongDateTime,
formatUnixTimeToLongDate, formatUnixTimeToLongDate,
getCalendarLongYearMonthFromUnixTime,
formatUnixTimeToShortTime, formatUnixTimeToShortTime,
formatUnixTimeToGregorianLikeLongYearMonth,
formatDateRange, formatDateRange,
formatAmountToLocalizedNumeralsWithCurrency formatAmountToLocalizedNumeralsWithCurrency
} = useI18n(); } = useI18n();
@@ -287,7 +287,7 @@ export function useTransactionListPageBase() {
} }
function getDisplayLongYearMonth(transactionMonthList: TransactionMonthList): string { function getDisplayLongYearMonth(transactionMonthList: TransactionMonthList): string {
return getCalendarLongYearMonthFromUnixTime(getYearMonthFirstUnixTime(transactionMonthList.yearDashMonth)); return formatUnixTimeToGregorianLikeLongYearMonth(getYearMonthFirstUnixTime(transactionMonthList.yearDashMonth));
} }
function getDisplayTimezone(transaction: Transaction): string { function getDisplayTimezone(transaction: Transaction): string {
@@ -63,7 +63,7 @@ const emit = defineEmits<{
const { const {
tt, tt,
getCurrentLanguageTextDirection, getCurrentLanguageTextDirection,
getCalendarShortMonthFromUnixTime, formatUnixTimeToGregorianLikeShortMonth,
formatAmountToLocalizedNumeralsWithCurrency formatAmountToLocalizedNumeralsWithCurrency
} = useI18n(); } = useI18n();
@@ -101,7 +101,7 @@ const chartOptions = computed<object>(() => {
if (props.data) { if (props.data) {
for (let i = 0; i < props.data.length; i++) { for (let i = 0; i < props.data.length; i++) {
const item = props.data[i]; const item = props.data[i];
const monthShortName = getCalendarShortMonthFromUnixTime(item.monthStartTime); const monthShortName = formatUnixTimeToGregorianLikeShortMonth(item.monthStartTime);
monthNames.push(monthShortName); monthNames.push(monthShortName);
incomeAmounts.push(item.incomeAmount); incomeAmounts.push(item.incomeAmount);
@@ -136,9 +136,9 @@ const {
tt, tt,
getCurrentLanguageTextDirection, getCurrentLanguageTextDirection,
getWeekdayShortName, getWeekdayShortName,
getCalendarLongYearMonthFromUnixTime, getCalendarDisplayDayOfMonthFromUnixTime,
formatUnixTimeToShortTime, formatUnixTimeToShortTime,
getCalendarDayOfMonthFromUnixTime, formatUnixTimeToGregorianLikeLongYearMonth,
formatAmountToLocalizedNumeralsWithCurrency formatAmountToLocalizedNumeralsWithCurrency
} = useI18n(); } = useI18n();
@@ -149,8 +149,8 @@ const fontSize = ref<number>(settingsStore.appSettings.fontSize);
const textDirection = computed<string>(() => getCurrentLanguageTextDirection()); const textDirection = computed<string>(() => getCurrentLanguageTextDirection());
const fontSizePreviewClassName = computed<string>(() => getFontSizePreviewClassName(fontSize.value)); const fontSizePreviewClassName = computed<string>(() => getFontSizePreviewClassName(fontSize.value));
const currentLongYearMonth = computed<string>(() => getCalendarLongYearMonthFromUnixTime(currentUnixTime.value)); const currentLongYearMonth = computed<string>(() => formatUnixTimeToGregorianLikeLongYearMonth(currentUnixTime.value));
const currentDayOfMonth = computed<string>(() => getCalendarDayOfMonthFromUnixTime(currentUnixTime.value)); const currentDayOfMonth = computed<string>(() => getCalendarDisplayDayOfMonthFromUnixTime(currentUnixTime.value));
const currentDayOfWeek = computed<string>(() => getWeekdayShortName(parseDateTimeFromUnixTime(currentUnixTime.value).getWeekDay())); const currentDayOfWeek = computed<string>(() => getWeekdayShortName(parseDateTimeFromUnixTime(currentUnixTime.value).getWeekDay()));
const currentShortTime = computed<string>(() => formatUnixTimeToShortTime(currentUnixTime.value)); const currentShortTime = computed<string>(() => formatUnixTimeToShortTime(currentUnixTime.value));
+3 -3
View File
@@ -536,7 +536,7 @@ const {
getMultiWeekdayLongNames, getMultiWeekdayLongNames,
formatUnixTimeToLongDate, formatUnixTimeToLongDate,
formatUnixTimeToLongTime, formatUnixTimeToLongTime,
formatGregorianCalendarYearDashMonthDashDayToLongDate formatGregorianTextualYearMonthDayToLongDate
} = useI18n(); } = useI18n();
const { showAlert, showConfirm, showToast, routeBackOnError } = useI18nUIComponents(); const { showAlert, showConfirm, showToast, routeBackOnError } = useI18nUIComponents();
@@ -756,7 +756,7 @@ const transactionDisplayScheduledStartDate = computed<string>(() => {
const template = transaction.value as TransactionTemplate; const template = transaction.value as TransactionTemplate;
if (template.scheduledStartDate) { if (template.scheduledStartDate) {
return formatGregorianCalendarYearDashMonthDashDayToLongDate(template.scheduledStartDate); return formatGregorianTextualYearMonthDayToLongDate(template.scheduledStartDate);
} else { } else {
return tt('No limit'); return tt('No limit');
} }
@@ -770,7 +770,7 @@ const transactionDisplayScheduledEndDate = computed<string>(() => {
const template = transaction.value as TransactionTemplate; const template = transaction.value as TransactionTemplate;
if (template.scheduledEndDate) { if (template.scheduledEndDate) {
return formatGregorianCalendarYearDashMonthDashDayToLongDate(template.scheduledEndDate); return formatGregorianTextualYearMonthDayToLongDate(template.scheduledEndDate);
} else { } else {
return tt('No limit'); return tt('No limit');
} }
+2 -2
View File
@@ -202,7 +202,7 @@
<template #media> <template #media>
<div class="display-flex flex-direction-column transaction-date" :style="getTransactionDateStyle(transaction, idx > 0 ? transactionMonthList.items[idx - 1] : null)"> <div class="display-flex flex-direction-column transaction-date" :style="getTransactionDateStyle(transaction, idx > 0 ? transactionMonthList.items[idx - 1] : null)">
<span class="transaction-day full-line flex-direction-column"> <span class="transaction-day full-line flex-direction-column">
{{ getCalendarDayOfMonthFromUnixTime(transaction.time) }} {{ getCalendarDisplayDayOfMonthFromUnixTime(transaction.time) }}
</span> </span>
<span class="transaction-day-of-week full-line flex-direction-column" v-if="transaction.displayDayOfWeek"> <span class="transaction-day-of-week full-line flex-direction-column" v-if="transaction.displayDayOfWeek">
{{ getWeekdayShortName(transaction.displayDayOfWeek) }} {{ getWeekdayShortName(transaction.displayDayOfWeek) }}
@@ -646,7 +646,7 @@ const {
getCurrentLanguageTextDirection, getCurrentLanguageTextDirection,
getAllTransactionTagFilterTypes, getAllTransactionTagFilterTypes,
getWeekdayShortName, getWeekdayShortName,
getCalendarDayOfMonthFromUnixTime getCalendarDisplayDayOfMonthFromUnixTime
} = useI18n(); } = useI18n();
const { showAlert, showToast, routeBackOnError } = useI18nUIComponents(); const { showAlert, showToast, routeBackOnError } = useI18nUIComponents();
+2 -2
View File
@@ -211,7 +211,7 @@
link="#" no-chevron link="#" no-chevron
class="list-item-with-header-and-title list-item-no-item-after" class="list-item-with-header-and-title list-item-no-item-after"
:header="tt('Fiscal Year Start Date')" :header="tt('Fiscal Year Start Date')"
:title="getCalendarLongMonthDayFromFiscalYearStart(newProfile.fiscalYearStart)" :title="formatFiscalYearStartToGregorianLikeLongMonth(newProfile.fiscalYearStart)"
@click="showFiscalYearStartSheet = true" @click="showFiscalYearStartSheet = true"
> >
<fiscal-year-start-selection-sheet <fiscal-year-start-selection-sheet
@@ -587,7 +587,7 @@ const {
getAllLanguageOptions, getAllLanguageOptions,
getAllCurrencies, getAllCurrencies,
getCurrencyName, getCurrencyName,
getCalendarLongMonthDayFromFiscalYearStart formatFiscalYearStartToGregorianLikeLongMonth
} = useI18n(); } = useI18n();
const { showAlert, showToast, routeBackOnError } = useI18nUIComponents(); const { showAlert, showToast, routeBackOnError } = useI18nUIComponents();