gitscope
https://dev.kronoz.win/r/marzneshin.git
dashboard/src/libs/stats-charts/hooks/use-from-now-interval.ts · v0.6.4
Source
1 6a4fee1 Dawsh 2y ago import { ChartDateInterval } from "../types";
2 6a4fee1 Dawsh 2y ago
3 6a4fee1 Dawsh 2y ago export function useFromNowInterval(interval: ChartDateInterval) {
4 6a4fee1 Dawsh 2y ago const start = new Date();
5 6a4fee1 Dawsh 2y ago const end = new Date();
6 6a4fee1 Dawsh 2y ago start.setDate(end.getDate() - parseInt(interval.replace("d", "")));
7 6a4fee1 Dawsh 2y ago end.setMinutes(0, 0, 0);
8 6a4fee1 Dawsh 2y ago start.setMinutes(0, 0, 0);
9 6a4fee1 Dawsh 2y ago return {
10 6a4fee1 Dawsh 2y ago start: start.toISOString(),
11 6a4fee1 Dawsh 2y ago end: end.toISOString()
12 6a4fee1 Dawsh 2y ago }
13 6a4fee1 Dawsh 2y ago }