From a7b1e659e8bc194880dbaa488c42e63c859607dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan=20Z=C3=ADpek?= Date: Mon, 3 Jun 2024 17:17:19 +0200 Subject: [PATCH] Improve events and align date a bit --- server/src/app/routes/dow.ts | 2 +- server/src/app/services/calendar.ts | 13 +++++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/server/src/app/routes/dow.ts b/server/src/app/routes/dow.ts index c17a1a9..3926e3d 100644 --- a/server/src/app/routes/dow.ts +++ b/server/src/app/routes/dow.ts @@ -103,7 +103,7 @@ export const dowRoutes = router((router, ctx) => { }, { x: WIDTH / 2, - y: 145, + y: 140, c: `${ Math.round((weather.now?.temperature as number) ?? 0) ?? '-' } C ${summary}`, diff --git a/server/src/app/services/calendar.ts b/server/src/app/services/calendar.ts index a8220a6..9807acf 100644 --- a/server/src/app/services/calendar.ts +++ b/server/src/app/services/calendar.ts @@ -21,7 +21,11 @@ export const calendarService = service((ctx) => async () => { events: async (calendars: string[]) => { const results = [] - const timeMin = DateTime.now().setZone(ctx.config.timeZone).startOf('day') + + const timeMin = DateTime.now() + .setZone(ctx.config.timeZone) + .minus({ minutes: 30 }) + const timeMax = DateTime.now().setZone(ctx.config.timeZone).endOf('day') if (!timeMin.isValid) { @@ -47,7 +51,12 @@ export const calendarService = service((ctx) => async () => { } } - return results + return results.sort((a, b) => { + const aDate = new Date(a.start?.dateTime ?? a.start?.date ?? 0) + const bDate = new Date(b.start?.dateTime ?? b.start?.date ?? 0) + + return aDate.toISOString().localeCompare(bDate.toISOString()) + }) }, } })