fix: restore BI quick date state
This commit is contained in:
@@ -40,6 +40,15 @@ export function normalizeDateRange(start: string, end: string): DateRangeValue {
|
||||
return start <= end ? { start, end } : { start: end, end: start };
|
||||
}
|
||||
|
||||
export function inferDateRangeMode(start: string, end: string, now = new Date()): DateRangeMode {
|
||||
const range = normalizeDateRange(start, end);
|
||||
const match = QUICK_DATE_OPTIONS.find(({ id }) => {
|
||||
const quickRange = getQuickDateRange(id, now);
|
||||
return quickRange.start === range.start && quickRange.end === range.end;
|
||||
});
|
||||
return match?.id ?? 'custom';
|
||||
}
|
||||
|
||||
export function dateRangeModeLabel(mode: DateRangeMode): string {
|
||||
return mode === 'custom' ? '自定义区间' : LABELS[mode];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user