code refactor

This commit is contained in:
MaysWind
2025-06-08 21:04:55 +08:00
parent f905dcb3fd
commit 51eb8fa377
3 changed files with 16 additions and 21 deletions
+2 -2
View File
@@ -30,7 +30,7 @@ export class FiscalYearStart {
}
public static of(month: number, day: number): FiscalYearStart | undefined {
if (!FiscalYearStart.isValidMonthDay(month, day)) {
if (!FiscalYearStart.isValidFiscalYearMonthDay(month, day)) {
return undefined;
}
@@ -79,7 +79,7 @@ export class FiscalYearStart {
return `${this.month.toString().padStart(2, '0')}-${this.day.toString().padStart(2, '0')}`;
}
private static isValidMonthDay(month: number, day: number): boolean {
private static isValidFiscalYearMonthDay(month: number, day: number): boolean {
return 1 <= month && month <= 12 && 1 <= day && day <= FiscalYearStart.MONTH_MAX_DAYS[month - 1];
}
}
+10 -15
View File
@@ -641,10 +641,6 @@ export function useI18n() {
return t('default.firstDayOfWeek');
}
function getDefaultFiscalYearFormat(): string {
return t('default.fiscalYearFormat');
}
function getAllLanguageOptions(includeSystemDefault: boolean): LanguageOption[] {
const ret: LanguageOption[] = [];
@@ -944,27 +940,27 @@ export function useI18n() {
}
const currentFiscalYearRange = getFiscalYearTimeRangeFromUnixTime(now, fiscalYearStart);
const ret: TypeAndDisplayName[] = [];
let defaultFiscalYearFormat = FiscalYearFormat.parse(t('default.fiscalYearFormat'));
let fiscalYearFormat = FiscalYearFormat.parse(getDefaultFiscalYearFormat());
if (!fiscalYearFormat) {
fiscalYearFormat = FiscalYearFormat.Default;
if (!defaultFiscalYearFormat) {
defaultFiscalYearFormat = FiscalYearFormat.Default;
}
const ret: TypeAndDisplayName[] = [];
ret.push({
type: LANGUAGE_DEFAULT_FISCAL_YEAR_FORMAT_VALUE,
displayName: `${t('Language Default')} (${formatTimeRangeToFiscalYearFormat(fiscalYearFormat, currentFiscalYearRange)})`
displayName: `${t('Language Default')} (${formatTimeRangeToFiscalYearFormat(defaultFiscalYearFormat, currentFiscalYearRange)})`
});
const allFiscalYearFormats = FiscalYearFormat.values();
for (let i = 0; i < allFiscalYearFormats.length; i++) {
const format = allFiscalYearFormats[i];
const fiscalYearFormat = allFiscalYearFormats[i];
ret.push({
type: format.type,
displayName: formatTimeRangeToFiscalYearFormat(format, currentFiscalYearRange),
type: fiscalYearFormat.type,
displayName: formatTimeRangeToFiscalYearFormat(fiscalYearFormat, currentFiscalYearRange),
});
}
@@ -1371,7 +1367,7 @@ export function useI18n() {
let fiscalYearFormat = FiscalYearFormat.valueOf(userStore.currentUserFiscalYearFormat);
if (!fiscalYearFormat) {
const defaultFiscalYearFormatTypeName = getDefaultFiscalYearFormat();
const defaultFiscalYearFormatTypeName = t('default.fiscalYearFormat');
fiscalYearFormat = FiscalYearFormat.parse(defaultFiscalYearFormatTypeName);
if (!fiscalYearFormat) {
@@ -1815,7 +1811,6 @@ export function useI18n() {
// get localization default type
getDefaultCurrency,
getDefaultFirstDayOfWeek,
getDefaultFiscalYearFormat,
// get all localized info of specified type
getAllLanguageOptions,
getAllEnableDisableOptions,