diff --git a/routes/publishedSchedule.js b/routes/publishedSchedule.js index c6b0935..e01abae 100644 --- a/routes/publishedSchedule.js +++ b/routes/publishedSchedule.js @@ -225,8 +225,8 @@ publishedScheduleRouter.post('/', async (req, res) => { ` UPDATE day SET - start_time = CASE WHEN $1::timestamp < start_time THEN $1::timestamp ELSE start_time END, - end_time = CASE WHEN $2::timestamp > end_time THEN $2::timestamp ELSE end_time END + start_time = CASE WHEN $1 < start_time THEN $1 ELSE start_time END, + end_time = CASE WHEN $2 > end_time THEN $2 ELSE end_time END WHERE id = $3; `, [startTime, endTime, dayId], @@ -392,14 +392,14 @@ publishedScheduleRouter.delete('/:id', async (req, res) => { await db.query(`DELETE FROM day WHERE id = $1`, [dayId]); } else { // if the event start time was the earliest change to earliest in PS table for that day - if (startTime.getTime() === dayResult.startTime.getTime()) { + if (startTime === dayResult.startTime) { await db.query( `UPDATE day SET start_time = (SELECT MIN(start_time) FROM published_schedule WHERE day_id = $1) WHERE id = $1`, [dayId], ); } // if the event end time was the latest change to latest in PS table for that day - if (endTime.getTime() === dayResult.endTime.getTime()) { + if (endTime === dayResult.endTime) { await db.query( `UPDATE day SET end_time = (SELECT MAX(end_time) FROM published_schedule WHERE day_id = $1) WHERE id = $1`, [dayId], diff --git a/server/schema/published_schedule.sql b/server/schema/published_schedule.sql index ddeff67..9d6de5c 100644 --- a/server/schema/published_schedule.sql +++ b/server/schema/published_schedule.sql @@ -5,8 +5,8 @@ CREATE TABLE IF NOT EXISTS published_schedule ( day_id integer NOT NULL, confirmed boolean NOT NULL, confirmed_on date NOT NULL, - start_time timestamp NOT NULL, - end_time timestamp NOT NULL, + start_time time NOT NULL, + end_time time NOT NULL, cohort varchar[] NOT NULL, notes varchar(100), FOREIGN KEY (event_id)