support filtering transactions by time zone minute offset, day of week, day of month, month of year and transaction hour in insights explorer

This commit is contained in:
MaysWind
2026-04-12 22:04:52 +08:00
parent d605a8f4ec
commit f214b7db88
27 changed files with 613 additions and 12 deletions
+69
View File
@@ -195,6 +195,7 @@ import {
} from '@/lib/common.ts';
import {
getCurrentDateTime,
formatCurrentTime,
formatGregorianCalendarYearDashMonthDashDay,
formatGregorianCalendarMonthDashDay,
@@ -1059,6 +1060,20 @@ export function useI18n() {
return getAllWeekdayNames('min');
}
function getAllMonths(): TypeAndDisplayName[] {
const ret: TypeAndDisplayName[] = [];
const allMonths = Month.values();
for (const month of allMonths) {
ret.push({
type: month.month,
displayName: t(`datetime.${month.name}.long`)
});
}
return ret;
}
function getAllWeekDays(firstDayOfWeek?: WeekDayValue): TypeAndDisplayName[] {
const ret: TypeAndDisplayName[] = [];
const allWeekDays = WeekDay.values();
@@ -1088,6 +1103,51 @@ export function useI18n() {
return ret;
}
function getAllHours(): TypeAndDisplayName[] {
const ret: TypeAndDisplayName[] = [];
const now: DateTime = getCurrentDateTime();
const format: string = getLocalizedShortTimeFormat();
const options: DateTimeFormatOptions = getDateTimeFormatOptions();
for (let i = 0; i < 24; i++) {
const dateTime = now.set({
hour: i,
minute: 0,
second: 0,
millisecond: 0
});
ret.push({
type: i,
displayName: dateTime.format(format, options)
});
}
return ret;
}
function getAvailableMonthDays(daysInMonth: number, lastDaysOfMonth?: number): TypeAndDisplayName[] {
const ret: TypeAndDisplayName[] = [];
for (let i = 1; i <= daysInMonth; i++) {
ret.push({
type: i,
displayName: getMonthdayShortName(i),
});
}
if (isNumber(lastDaysOfMonth) && lastDaysOfMonth > 0) {
for (let i = -lastDaysOfMonth; i < 0; i++) {
ret.push({
type: i,
displayName: (i === -1) ? t('Last day') : getMonthLastDayShortName(-i),
});
}
}
return ret;
}
function getLocalizedDateTimeFormats<T extends DateFormat | TimeFormat>(type: string, allFormatMap: Record<string, T>, allFormatArray: T[], languageDefaultTypeNameKey: string, systemDefaultFormatType: T, numeralSystem: NumeralSystem, calendarType?: CalendarType): LocalizedDateTimeFormat[] {
const defaultFormat = getLocalizedDateTimeFormat<T>(type, allFormatMap, allFormatArray, LANGUAGE_DEFAULT_DATE_TIME_FORMAT_VALUE, languageDefaultTypeNameKey, systemDefaultFormatType);
const ret: LocalizedDateTimeFormat[] = [];
@@ -1606,6 +1666,12 @@ export function useI18n() {
});
}
function getMonthLastDayShortName(ordinal: number): string {
return t('format.misc.lastMonthDay', {
ordinal: getMonthdayOrdinal(ordinal)
});
}
function getWeekdayShortName(weekDay: WeekDay): string {
return t(`datetime.${weekDay.name}.short`);
}
@@ -2411,7 +2477,10 @@ export function useI18n() {
getAllLongWeekdayNames,
getAllShortWeekdayNames,
getAllMinWeekdayNames,
getAllMonths,
getAllWeekDays,
getAllHours,
getAvailableMonthDays,
getAllCalendarDisplayTypes: () => getAllLocalizedCalendarTypes(CalendarDisplayType.values(), CalendarDisplayType.parse(t('default.calendarDisplayType')), CalendarDisplayType.Default, CalendarDisplayType.LanguageDefaultType),
getAllDateDisplayTypes: () => getAllLocalizedCalendarTypes(DateDisplayType.values(), DateDisplayType.parse(t('default.dateDisplayType')), DateDisplayType.Default, DateDisplayType.LanguageDefaultType),
getAllLongDateFormats: (numeralSystem: NumeralSystem, calendarType: CalendarType) => getLocalizedDateTimeFormats<LongDateFormat>('longDate', LongDateFormat.all(), LongDateFormat.values(), 'longDateFormat', LongDateFormat.Default, numeralSystem, calendarType),