From 4576b7261287dc59d5396162635cb935fab597c6 Mon Sep 17 00:00:00 2001 From: sudoer777 <78781902+sudoer777@users.noreply.github.com> Date: Sun, 21 Nov 2021 17:37:45 -0700 Subject: [PATCH] Switch date from native object to moment.js --- database/scores/games.js | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/database/scores/games.js b/database/scores/games.js index b990a31..8d49aeb 100644 --- a/database/scores/games.js +++ b/database/scores/games.js @@ -1,4 +1,5 @@ const database = require('./../database'); +const moment = require('moment'); @@ -22,11 +23,7 @@ async function add(divisionID, seasonID, date, team1ID, team2ID, team1Score, tea VALUES($1, $2, $3, $4, $5, $6, $7) RETURNING game_id;`; - const day = ("0" + date.getDate()).slice(-2); - const month = ("0" + (date.getMonth() + 1)).slice(-2); - const year = date.getFullYear(); - - const dateISO = year + '-' + month + '-' + day; + const dateISO = date.format(YYYY-MM-DD); const id = (await database.executeQuery(query, [divisionID, seasonID, dateISO, team1ID, team2ID, team1Score, team2Score]))[0][0]; return new Game(id, date, team1ID, team2ID, team1Score, team2Score);