From 69cceac851229955d54b7d1646fbb51215ef16bb Mon Sep 17 00:00:00 2001 From: Christopher Rotnes Date: Mon, 4 May 2026 16:43:41 +0200 Subject: [PATCH] fix #99: use period_start/period_end params for sporty.no date range MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The API was ignoring from/to — correct parameter names are period_start and period_end with full ISO datetimes. Anchors to Oslo midnight (previous day T22:00:00.000Z, CEST=UTC+2) to match sporty.no's own request format. Co-Authored-By: Claude Sonnet 4.6 --- app/api/sportySync.js | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/api/sportySync.js b/app/api/sportySync.js index d377871..252424a 100644 --- a/app/api/sportySync.js +++ b/app/api/sportySync.js @@ -4,9 +4,15 @@ const SPORTY_BASE_URL = 'https://sporty.no/api/v1/businessunits/8/groupactivities'; function buildSportyUrl(daysAhead = 10) { - const from = new Date().toISOString().slice(0, 10); - const to = new Date(Date.now() + daysAhead * 24 * 60 * 60 * 1000).toISOString().slice(0, 10); - return `${SPORTY_BASE_URL}?from=${from}&to=${to}`; + // sporty.no uses Oslo midnight = previous day T22:00:00.000Z (CEST / UTC+2) + const start = new Date(); + start.setUTCHours(22, 0, 0, 0); + start.setUTCDate(start.getUTCDate() - 1); + + const end = new Date(start); + end.setUTCDate(end.getUTCDate() + daysAhead); + + return `${SPORTY_BASE_URL}?period_start=${encodeURIComponent(start.toISOString())}&period_end=${encodeURIComponent(end.toISOString())}`; } function shiftRow(row, shiftMs) {