ability to use custom dates everywhere
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import { isSameDay, isSameMonth } from 'date-fns';
|
||||
|
||||
export const NOT_SET_VALUE = '(not set)';
|
||||
|
||||
export const operators = {
|
||||
@@ -100,3 +102,19 @@ export function getDefaultIntervalByRange(
|
||||
}
|
||||
return 'month';
|
||||
}
|
||||
|
||||
export function getDefaultIntervalByDates(
|
||||
startDate: string | null,
|
||||
endDate: string | null
|
||||
): null | keyof typeof intervals {
|
||||
if (startDate && endDate) {
|
||||
if (isSameDay(startDate, endDate)) {
|
||||
return 'hour';
|
||||
} else if (isSameMonth(startDate, endDate)) {
|
||||
return 'day';
|
||||
}
|
||||
return 'month';
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@
|
||||
"@mixan/eslint-config": "workspace:*",
|
||||
"@mixan/prettier-config": "workspace:*",
|
||||
"@mixan/tsconfig": "workspace:*",
|
||||
"date-fns": "^3.3.1",
|
||||
"eslint": "^8.48.0",
|
||||
"prettier": "^3.0.3",
|
||||
"prisma": "^5.1.1",
|
||||
|
||||
Reference in New Issue
Block a user