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);