Switch date from native object to moment.js
parent
7d4dcc4d82
commit
4576b72612
|
@ -1,4 +1,5 @@
|
||||||
const database = require('./../database');
|
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)
|
VALUES($1, $2, $3, $4, $5, $6, $7)
|
||||||
RETURNING game_id;`;
|
RETURNING game_id;`;
|
||||||
|
|
||||||
const day = ("0" + date.getDate()).slice(-2);
|
const dateISO = date.format(YYYY-MM-DD);
|
||||||
const month = ("0" + (date.getMonth() + 1)).slice(-2);
|
|
||||||
const year = date.getFullYear();
|
|
||||||
|
|
||||||
const dateISO = year + '-' + month + '-' + day;
|
|
||||||
|
|
||||||
const id = (await database.executeQuery(query, [divisionID, seasonID, dateISO, team1ID, team2ID, team1Score, team2Score]))[0][0];
|
const id = (await database.executeQuery(query, [divisionID, seasonID, dateISO, team1ID, team2ID, team1Score, team2Score]))[0][0];
|
||||||
return new Game(id, date, team1ID, team2ID, team1Score, team2Score);
|
return new Game(id, date, team1ID, team2ID, team1Score, team2Score);
|
||||||
|
|
Reference in New Issue