Timezone compensation

This commit is contained in:
Felix Albrigtsen 2022-04-20 14:34:57 +02:00
parent 184ed8413b
commit 5cfed3a3bf
1 changed files with 7 additions and 6 deletions

View File

@ -107,8 +107,8 @@ api.post("/tournament/:tournamentId/edit", (req, res) => {
return return
} }
try { try {
startDate = new Date(startDate); startDate = new Date(parseInt(startDate));
endDate = new Date(endDate); endDate = new Date(parseInt(endDate));
} catch (err) { } catch (err) {
res.json({"status": "error", "data": "startDate and endDate must be valid dates"}); res.json({"status": "error", "data": "startDate and endDate must be valid dates"});
return return
@ -262,6 +262,7 @@ api.post("/tournament/create", (req, res) => {
let teamLimit = req.body.teamLimit; let teamLimit = req.body.teamLimit;
let startDate = req.body.startDate; //TODO: timezones, 2 hr skips let startDate = req.body.startDate; //TODO: timezones, 2 hr skips
let endDate = req.body.endDate; let endDate = req.body.endDate;
console.log(startDate, endDate);
if (name == undefined || name == "" || description == undefined || description == "") { if (name == undefined || name == "" || description == undefined || description == "") {
res.json({"status": "error", "data": "name and description must be provided"}); res.json({"status": "error", "data": "name and description must be provided"});
return return
@ -281,8 +282,8 @@ api.post("/tournament/create", (req, res) => {
return return
} }
try { try {
startDate = new Date(startDate); startDate = new Date(parseInt(startDate));
endDate = new Date(endDate); endDate = new Date(parseInt(endDate));
} catch (err) { } catch (err) {
res.json({"status": "error", "data": "startDate and endDate must be valid dates"}); res.json({"status": "error", "data": "startDate and endDate must be valid dates"});
return return
@ -293,14 +294,14 @@ api.post("/tournament/create", (req, res) => {
return return
} }
if (startDate > endDate) { 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 return
} }
console.log(startDate);
tmdb.createTournament(name, description, startDate, endDate, teamLimit) tmdb.createTournament(name, description, startDate, endDate, teamLimit)
.then(msg => res.json({"status": "OK", "data": msg})) .then(msg => res.json({"status": "OK", "data": msg}))
.catch(err => res.json({"status": "error", "data": err})); .catch(err => res.json({"status": "error", "data": err}));
}); });
// #endregion // #endregion