fix date formatting
This commit is contained in:
@@ -6,18 +6,16 @@ import { redirect } from '@sveltejs/kit';
|
|||||||
import type { RequestEvent } from '@sveltejs/kit';
|
import type { RequestEvent } from '@sveltejs/kit';
|
||||||
import { configFile, type Config, type Session } from '$models/config';
|
import { configFile, type Config, type Session } from '$models/config';
|
||||||
import { set } from 'lodash-es';
|
import { set } from 'lodash-es';
|
||||||
import { format } from 'date-fns-tz';
|
import { subDays, formatISO } from 'date-fns';
|
||||||
import { subDays } from 'date-fns';
|
|
||||||
|
|
||||||
export const load = async (event: RequestEvent) => {
|
export const load = async (event: RequestEvent) => {
|
||||||
const isAuth = await checkAuth(event);
|
const isAuth = await checkAuth(event);
|
||||||
if (!isAuth) return redirect(308, '/login');
|
if (!isAuth) return redirect(308, '/login');
|
||||||
if (!event.params.id) return redirect(308, '/dashboard');
|
if (!event.params.id) return redirect(308, '/dashboard');
|
||||||
const today = format(new Date(), 'yyyy-MM-ddTHH:mm:ssZ');
|
const today = new Date();
|
||||||
const thirtyDaysAgo = format(subDays(new Date(), 30), 'yyyy-MM-ddTHH:mm:ssZ');
|
const endDate = formatISO(today);
|
||||||
|
const startDate = formatISO(subDays(today, 30));
|
||||||
|
|
||||||
const endDate = today;
|
|
||||||
const startDate = thirtyDaysAgo;
|
|
||||||
const [server, configs, tracks, stateHistory] = await Promise.all([
|
const [server, configs, tracks, stateHistory] = await Promise.all([
|
||||||
getServerById(event, event.params.id),
|
getServerById(event, event.params.id),
|
||||||
getConfigFiles(event, event.params.id),
|
getConfigFiles(event, event.params.id),
|
||||||
|
|||||||
Reference in New Issue
Block a user