From a9a52c17a1cd55ee5c53fc4e840ef123a3488c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20=C3=96hlerking?= Date: Wed, 11 Sep 2024 17:17:46 +0200 Subject: [PATCH 1/2] fix course time stamps --- controllers/courses.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/controllers/courses.js b/controllers/courses.js index 00a2b87243..dca04cb06c 100644 --- a/controllers/courses.js +++ b/controllers/courses.js @@ -303,6 +303,11 @@ const editCourseHandler = (req, res, next) => { course.name = group.name; course.teacherIds = getUserIdsByRole(group.users, 'teacher'); course.userIds = getUserIdsByRole(group.users, 'student'); + + if (group.validPeriod) { + course.startDate = timesHelper.fromUTC(group.validPeriod.from); + course.untilDate = timesHelper.fromUTC(group.validPeriod.until); + } } const syncedElements = (course.syncedWithGroup || syncedGroupId) ? getSyncedElements( From 50011a4da8cf420c2cc61692ec5c2120f8a9bd27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marvin=20=C3=96hlerking?= Date: Thu, 12 Sep 2024 09:47:12 +0200 Subject: [PATCH 2/2] add time to date --- controllers/courses.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/controllers/courses.js b/controllers/courses.js index dca04cb06c..a646f8c4c5 100644 --- a/controllers/courses.js +++ b/controllers/courses.js @@ -65,8 +65,12 @@ const getSyncedElements = ( res, syncedWithGroup, ) => { - const startDate = course.startDate ? timesHelper.formatDate(course.startDate, 'DD.MM.YYYY') : undefined; - const untilDate = course.untilDate ? timesHelper.formatDate(course.untilDate, 'DD.MM.YYYY') : undefined; + const startDate = course.startDate + ? timesHelper.formatDate(course.startDate, timesHelper.FORMAT.dateTime) + : undefined; + const untilDate = course.untilDate + ? timesHelper.formatDate(course.untilDate, timesHelper.FORMAT.dateTime) + : undefined; const selectedElements = { teachersSelected: selectedElementIdsToString(markSelected(teachers, course.teacherIds)), @@ -842,8 +846,8 @@ router.patch('/:courseId', async (req, res, next) => { const keys = ['teacherIds', 'substitutionIds', 'classIds', 'userIds']; req.body = strToPropsArray(req.body, keys); - const startDate = timesHelper.dateStringToMoment(req.body.startDate); - const untilDate = timesHelper.dateStringToMoment(req.body.untilDate); + const startDate = timesHelper.dateTimeStringToMoment(req.body.startDate).utc(); + const untilDate = timesHelper.dateTimeStringToMoment(req.body.untilDate).utc(); delete req.body.startDate; if (startDate.isValid()) {