Switch date from native object to moment.js

main
sudoer777 2021-11-21 17:37:45 -07:00
parent 7d4dcc4d82
commit 4576b72612
1 changed files with 2 additions and 5 deletions

View File

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