From 5cfed3a3bf955bd58f7ac8ce3cb83da55d92d436 Mon Sep 17 00:00:00 2001 From: Felix Albrigtsen Date: Wed, 20 Apr 2022 14:34:57 +0200 Subject: [PATCH] Timezone compensation --- src/server/index.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/server/index.js b/src/server/index.js index ff60022..a437ba9 100644 --- a/src/server/index.js +++ b/src/server/index.js @@ -107,8 +107,8 @@ api.post("/tournament/:tournamentId/edit", (req, res) => { return } try { - startDate = new Date(startDate); - endDate = new Date(endDate); + startDate = new Date(parseInt(startDate)); + endDate = new Date(parseInt(endDate)); } catch (err) { res.json({"status": "error", "data": "startDate and endDate must be valid dates"}); return @@ -262,6 +262,7 @@ api.post("/tournament/create", (req, res) => { let teamLimit = req.body.teamLimit; let startDate = req.body.startDate; //TODO: timezones, 2 hr skips let endDate = req.body.endDate; + console.log(startDate, endDate); if (name == undefined || name == "" || description == undefined || description == "") { res.json({"status": "error", "data": "name and description must be provided"}); return @@ -281,8 +282,8 @@ api.post("/tournament/create", (req, res) => { return } try { - startDate = new Date(startDate); - endDate = new Date(endDate); + startDate = new Date(parseInt(startDate)); + endDate = new Date(parseInt(endDate)); } catch (err) { res.json({"status": "error", "data": "startDate and endDate must be valid dates"}); return @@ -293,14 +294,14 @@ api.post("/tournament/create", (req, res) => { return } if (startDate > endDate) { - res.json({"status": "error", "data": "startDate cannot be after endDate"}); + res.json({"status": "error", "data": "endDate must be later than startDate"}); return } + console.log(startDate); tmdb.createTournament(name, description, startDate, endDate, teamLimit) .then(msg => res.json({"status": "OK", "data": msg})) .catch(err => res.json({"status": "error", "data": err})); - }); // #endregion