Commit 0afac4ef authored by Michael Koch's avatar Michael Koch
Browse files

Replace moment.js with day.js. Also don't be lazy, do date stuff properly. No...

Replace moment.js with day.js. Also don't be lazy, do date stuff properly. No more blind search+replace!
parent 6bea3bbc
......@@ -31,7 +31,8 @@
<script type="text/javascript" src="node_modules/angular/angular.min.js"></script>
<script type="text/javascript" src="node_modules/angular-sanitize/angular-sanitize.min.js"></script>
<script type="text/javascript" src="node_modules/jquery-datetimepicker/build/jquery.datetimepicker.full.min.js"></script>
<script type="text/javascript" src="node_modules/moment/min/moment-with-locales.min.js"></script>
<script type="text/javascript" src="node_modules/dayjs/dayjs.min.js"></script>
<script type="text/javascript" src="node_modules/dayjs/locale/de.js"></script>
<script type="text/javascript" src="node_modules/@fullcalendar/core/main.min.js"></script>
<script type="text/javascript" src="node_modules/@fullcalendar/daygrid/main.min.js"></script>
<script type="text/javascript" src="node_modules/@fullcalendar/timegrid/main.min.js"></script>
......
......@@ -101,12 +101,12 @@ async function setupLandingCalendar() {
(info.event._def.extendedProps.reservation.confirmed === 1 ? '<br /><br /><b>BEST&Auml;TIGT</b>' : '') +
(info.event._def.extendedProps.reservation.denied === 1 ? '<br /><br /><b>ABGELEHNT</b>' : '') +
"<br /><br /><b>Zeitraum " + (info.event._def.extendedProps.room.room_type === 1 ? "Lernsprint" : (info.event._def.extendedProps.room.room_type === 5 ? "StudySpace" : "Veranstaltung")) + ":</b><br />" +
_getLocalDateTimeShort(moment(info.event._def.extendedProps.reservation.event.from)._d) + " bis<br />" +
_getLocalDateTimeShort(moment(info.event._def.extendedProps.reservation.event.to)._d) +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.event.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.event.to) +
(info.view.type !== "timeGridWeek" && _validateDate(info.event._def.extendedProps.reservation.preparation.from, 'YYYY-MM-DD HH:mm') ?
"<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br />" +
_getLocalDateTimeShort(moment(info.event._def.extendedProps.reservation.preparation.from)._d) + " bis<br />" +
_getLocalDateTimeShort(moment(info.event._def.extendedProps.reservation.preparation.to)._d)
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.to)
: "") +
"<br /><br /><b>Buchender:</b><br />" +
info.event._def.extendedProps.reservation.contact.name + "<br />" +
......@@ -122,8 +122,8 @@ async function setupLandingCalendar() {
$(info.el).tooltip({
content: "<b>" + info.event._def.extendedProps.reservation.subject + "</b>" +
"<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br />" +
_getLocalDateTimeShort(moment(info.event._def.extendedProps.reservation.preparation.from)._d) + " bis<br />" +
_getLocalDateTimeShort(moment(info.event._def.extendedProps.reservation.preparation.to)._d),
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.to),
track: true
});
}
......@@ -175,11 +175,11 @@ async function setupFrontendCalendar() {
(info.event._def.extendedProps.reservation.confirmed === 1 ? '<br /><br /><b>BEST&Auml;TIGT</b>' : '') +
(info.event._def.extendedProps.reservation.denied === 1 ? '<br /><br /><b>ABGELEHNT</b>' : '') +
(info.view.type === "dayGridMonth" && _validateDate(info.event._def.extendedProps.reservation.preparation.from, 'YYYY-MM-DD HH:mm') ? "<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br />" +
_getLocalDateTimeShort(moment(info.event._def.extendedProps.reservation.preparation.from)._d) + " bis<br />" +
_getLocalDateTimeShort(moment(info.event._def.extendedProps.reservation.preparation.to)._d) : "") +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.to) : "") +
"<br /><br /><b>Zeitraum " + (info.event._def.extendedProps.room.room_type === 1 ? "Lernsprint" : (info.event._def.extendedProps.room.room_type === 5 ? "StudySpace" : "Veranstaltung")) + ":</b><br />" +
_getLocalDateTimeShort(moment(info.event._def.extendedProps.reservation.event.from)._d) + " bis<br />" +
_getLocalDateTimeShort(moment(info.event._def.extendedProps.reservation.event.to)._d),
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.event.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.event.to),
track: true
});
} else if (info.event._def.extendedProps.timeslot === "preparation") {
......@@ -187,8 +187,8 @@ async function setupFrontendCalendar() {
$(info.el).tooltip({
content: "<b>Buchung Nr. " + info.event._def.extendedProps.reservation.id + "</b>" +
"<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br />" +
_getLocalDateTimeShort(moment(info.event._def.extendedProps.reservation.preparation.from)._d) + " bis<br />" +
_getLocalDateTimeShort(moment(info.event._def.extendedProps.reservation.preparation.to)._d),
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.from) + " bis<br />" +
_getLocalDateTimeShort(info.event._def.extendedProps.reservation.preparation.to),
track: true
});
}
......@@ -250,8 +250,8 @@ function fillLandingCalendar() {
$.each(_events.unconfirmed, (i, e) => {
_calendars.landing.addEvent({
title: e.room.shortname.substring(0,3).toUpperCase() + " - " + e.subject + " (" + e.contact.name + ")",
start: moment(e.event.from)._d,
end: moment(e.event.to)._d,
start: dayjs(e.event.from).$d,
end: dayjs(e.event.to).$d,
color: e.room.calendar_color,
textColor: _isColorLight(e.room.calendar_color) ? '#000000' : '#ffffff',
extendedProps: {
......@@ -263,8 +263,8 @@ function fillLandingCalendar() {
});
_calendars.landing.addEvent({
title: '',
start: moment(e.preparation.from)._d,
end: moment(e.preparation.to)._d,
start: dayjs(e.preparation.from).$d,
end: dayjs(e.preparation.to).$d,
color: e.room.calendar_color,
textColor: _isColorLight(e.room.calendar_color) ? '#000000' : '#ffffff',
rendering: 'background',
......@@ -311,8 +311,8 @@ function fillLandingCalendar() {
$.each(_events.confirmed, (i, e) => {
_calendars.landing.addEvent({
title: e.room.shortname.substring(0,3).toUpperCase() + " - " + e.subject + " (" + e.contact.name + ")",
start: moment(e.event.from)._d,
end: moment(e.event.to)._d,
start: dayjs(e.event.from).$d,
end: dayjs(e.event.to).$d,
color: e.room.calendar_color_confirmed,
textColor: _isColorLight(e.room.calendar_color_confirmed) ? '#000000' : '#ffffff',
extendedProps: {
......@@ -324,8 +324,8 @@ function fillLandingCalendar() {
});
_calendars.landing.addEvent({
title: '',
start: moment(e.preparation.from)._d,
end: moment(e.preparation.to)._d,
start: dayjs(e.preparation.from).$d,
end: dayjs(e.preparation.to).$d,
color: e.room.calendar_color_confirmed,
textColor: _isColorLight(e.room.calendar_color_confirmed) ? '#000000' : '#ffffff',
rendering: 'background',
......@@ -397,8 +397,8 @@ function fillFrontendCalendar() {
$.each(_frontendEvents.unconfirmed, (i, e) => {
_calendars.frontend.addEvent({
title: e.room.shortname.substring(0,3).toUpperCase() + " - #" + e.id,
start: moment(e.event.from)._d,
end: moment(e.event.to)._d,
start: dayjs(e.event.from).$d,
end: dayjs(e.event.to).$d,
color: e.room.calendar_color,
textColor: _isColorLight(e.room.calendar_color) ? '#000000' : '#ffffff',
extendedProps: {
......@@ -410,8 +410,8 @@ function fillFrontendCalendar() {
});
_calendars.frontend.addEvent({
title: '',
start: moment(e.preparation.from)._d,
end: moment(e.preparation.to)._d,
start: dayjs(e.preparation.from).$d,
end: dayjs(e.preparation.to).$d,
color: e.room.calendar_color,
textColor: _isColorLight(e.room.calendar_color) ? '#000000' : '#ffffff',
rendering: 'background',
......@@ -458,8 +458,8 @@ function fillFrontendCalendar() {
$.each(_frontendEvents.confirmed, (i, e) => {
_calendars.frontend.addEvent({
title: e.room.shortname.substring(0,3).toUpperCase() + " - #" + e.id,
start: moment(e.event.from)._d,
end: moment(e.event.to)._d,
start: dayjs(e.event.from).$d,
end: dayjs(e.event.to).$d,
color: e.room.calendar_color_confirmed,
textColor: _isColorLight(e.room.calendar_color_confirmed) ? '#000000' : '#ffffff',
extendedProps: {
......@@ -471,8 +471,8 @@ function fillFrontendCalendar() {
});
_calendars.frontend.addEvent({
title: '',
start: moment(e.preparation.from)._d,
end: moment(e.preparation.to)._d,
start: dayjs(e.preparation.from).$d,
end: dayjs(e.preparation.to).$d,
color: e.room.calendar_color_confirmed,
textColor: _isColorLight(e.room.calendar_color_confirmed) ? '#000000' : '#ffffff',
rendering: 'background',
......
......@@ -134,13 +134,13 @@ function detectRoomSelection() {
$("#new_reservation_to_event").datetimepicker({ minDate: _getFormattedDate(_addDays(new Date(), 7)), timepicker: false, defaultTime: '22:00', disabledWeekDays: [] });
}
if (_validateDate($("#new_reservation_from_event").val(), 'YYYY-MM-DD HH:mm')) {
let minD = _getFormattedDate(moment($("#new_reservation_from_event").val())._d);
let maxD = _getFormattedDate(_addDays(moment($("#new_reservation_from_event").val())._d, 7));
let minD = _getFormattedDate($("#new_reservation_from_event").val());
let maxD = _getFormattedDate(_addDays($("#new_reservation_from_event").val(), 7));
$("#new_reservation_to_event").datetimepicker({ minDate: minD, maxDate: maxD });
}
if (_validateDate($("#new_reservation_to_event").val(), 'YYYY-MM-DD HH:mm')) {
let minD = _getFormattedDate(_.max([_addDays(moment($("#new_reservation_to_event").val())._d, -7), _addDays(new Date(), 1)]));
let maxD = _getFormattedDate(moment($("#new_reservation_to_event").val())._d);
let minD = _getFormattedDate(_.max([_addDays($("#new_reservation_to_event").val(), -7), _addDays(new Date(), 1)]));
let maxD = _getFormattedDate($("#new_reservation_to_event").val());
$("#new_reservation_from_event").datetimepicker({ minDate: minD, maxDate: maxD });
}
} else {
......@@ -162,21 +162,21 @@ function detectRoomSelection() {
$("#new_reservation_from_event").datetimepicker({ timepicker: true });
$("#new_reservation_to_event").datetimepicker({ timepicker: true });
if (_validateDate($("#new_reservation_from_preparation").val(), 'YYYY-MM-DD HH:mm')) {
$("#new_reservation_from_event").datetimepicker({ useCurrent: false, minDate: _getFormattedDate(moment($("#new_reservation_from_preparation").val())._d) });
$("#new_reservation_to_preparation").datetimepicker({ useCurrent: false, minDate: _getFormattedDate(moment($("#new_reservation_from_preparation").val())._d) });
$("#new_reservation_from_event").datetimepicker({ useCurrent: false, minDate: _getFormattedDate($("#new_reservation_from_preparation").val()) });
$("#new_reservation_to_preparation").datetimepicker({ useCurrent: false, minDate: _getFormattedDate($("#new_reservation_from_preparation").val()) });
}
if (_validateDate($("#new_reservation_to_preparation").val(), 'YYYY-MM-DD HH:mm')) {
$("#new_reservation_from_preparation").datetimepicker({ useCurrent: false, maxDate: _getFormattedDate(moment($("#new_reservation_to_preparation").val())._d) });
$("#new_reservation_from_event").datetimepicker({ useCurrent: false, maxDate: _getFormattedDate(moment($("#new_reservation_to_preparation").val())._d) });
$("#new_reservation_to_event").datetimepicker({ useCurrent: false, maxDate: _getFormattedDate(moment($("#new_reservation_to_preparation").val())._d) });
$("#new_reservation_from_preparation").datetimepicker({ useCurrent: false, maxDate: _getFormattedDate($("#new_reservation_to_preparation").val()) });
$("#new_reservation_from_event").datetimepicker({ useCurrent: false, maxDate: _getFormattedDate($("#new_reservation_to_preparation").val()) });
$("#new_reservation_to_event").datetimepicker({ useCurrent: false, maxDate: _getFormattedDate($("#new_reservation_to_preparation").val()) });
}
if (_validateDate($("#new_reservation_from_event").val(), 'YYYY-MM-DD HH:mm')) {
$("#new_reservation_from_preparation").datetimepicker({ useCurrent: false, maxDate: _getFormattedDate(moment($("#new_reservation_from_event").val())._d) });
$("#new_reservation_to_event").datetimepicker({ useCurrent: false, minDate: _getFormattedDate(moment($("#new_reservation_from_event").val())._d) });
$("#new_reservation_from_preparation").datetimepicker({ useCurrent: false, maxDate: _getFormattedDate($("#new_reservation_from_event").val()) });
$("#new_reservation_to_event").datetimepicker({ useCurrent: false, minDate: _getFormattedDate($("#new_reservation_from_event").val()) });
}
if (_validateDate($("#new_reservation_to_event").val(), 'YYYY-MM-DD HH:mm')) {
$("#new_reservation_to_preparation").datetimepicker({ useCurrent: false, minDate: _getFormattedDate(moment($("#new_reservation_to_event").val())._d) });
$("#new_reservation_from_event").datetimepicker({ useCurrent: false, maxDate: _getFormattedDate(moment($("#new_reservation_to_event").val())._d) });
$("#new_reservation_to_preparation").datetimepicker({ useCurrent: false, minDate: _getFormattedDate($("#new_reservation_to_event").val()) });
$("#new_reservation_from_event").datetimepicker({ useCurrent: false, maxDate: _getFormattedDate($("#new_reservation_to_event").val()) });
}
$("#new_reservation_from_event").removeClass("longer");
$("#new_reservation_from_event").addClass("long");
......@@ -268,14 +268,14 @@ function checkNewReservationForm() {
};
}
if (moment($("#new_reservation_from_event").val())._d >= moment($("#new_reservation_to_event").val())) {
if (dayjs($("#new_reservation_from_event").val()).$d >= moment($("#new_reservation_to_event").val())) {
return {
'success': false,
'reason': 'from_event_after_to_event'
};
}
if (_addDays(moment($("#new_reservation_from_event").val())._d, 7) <= moment($("#new_reservation_to_event").val())._d) {
if (_addDays(dayjs($("#new_reservation_from_event").val())._d, 7) <= moment($("#new_reservation_to_event").val()).$d) {
return {
'success': false,
'reason': 'event_longer_than_week'
......
......@@ -27,10 +27,8 @@ function setupLandingGraph() {
const ctx = $("#landing_graph_canvas")[0].getContext("2d");
let l = [];
const newReservations = [];
const weekdayShort = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
const numdays = 7;
let date = new Date();
date.setDate(date.getDate() - (numdays + 1));
let date = dayjs().subtract(numdays + 1, "days");
function iterate_dates(count) {
if (count < 0) {
......@@ -79,10 +77,10 @@ function setupLandingGraph() {
$("#landing_graph_canvas").show();
$("#landing_graph_placeholder").hide();
} else {
date = moment(date.setDate(date.getDate() + 1))._d;
date = dayjs(date).add(1, 'days');
_callBackend({"cmd": "getReservationCountForDate", "date": _getFormattedDate(date)}, (r) => {
if (r.result === "success") {
l.push(date.getDate());
l.push(date.get('date'));
newReservations.push(r.content);
count--;
iterate_dates(count);
......
......@@ -132,7 +132,7 @@ function showNewOffense() {
offender_string += "<option value='" + offender.id + "'>" + offender.name + "</option>");
$("#new_offense_offender").prepend(offender_string);
$.each(offense_reservations, (i, reservation) =>
$("#new_offense_reservation").append("<option value='" + reservation.id + "'>" + reservation.id + " - " + reservation.subject + " (" + reservation.contact.name + ", " + _getLocalDateTime(moment(reservation.preparation.from)._d) + ")"));
$("#new_offense_reservation").append("<option value='" + reservation.id + "'>" + reservation.id + " - " + reservation.subject + " (" + reservation.contact.name + ", " + _getLocalDateTime(reservation.preparation.from) + ")"));
$("#new_offense_offender").val(preselected_offender);
checkNewOffender();
if ($('#message').hasClass('ui-dialog-content')) msg.dialog('open');
......@@ -174,7 +174,7 @@ function showOffensesForOffender(fieldorid) {
"<tbody></tbody>" +
"</table>", "Verstöße");
$.each(o, (i, offense) =>
$("#offenses_table_" + id + " tbody").append("<tr class='clickable' onclick='showOffenseDetails(" + offense.id + ");'><td>" + offense.id + "</td><td>" + offense.reservation.id + "</td><td>" + offense.reservation.contact.name + "</td><td>" + _truncString(offense.reason, 40, "") + "</td><td>" + _getLocalDateTime(moment(offense.date)._d) + "</td></tr>"));
$("#offenses_table_" + id + " tbody").append("<tr class='clickable' onclick='showOffenseDetails(" + offense.id + ");'><td>" + offense.id + "</td><td>" + offense.reservation.id + "</td><td>" + offense.reservation.contact.name + "</td><td>" + _truncString(offense.reason, 40, "") + "</td><td>" + _getLocalDateTime(offense.date) + "</td></tr>"));
}
/**
......@@ -198,11 +198,11 @@ function showOffenseDetails(id) {
"</tr>" +
"<tr>" +
"<td><b>Datum, Uhrzeit:</b></td>" +
"<td>" + _getLocalDateTime(moment(o.date)._d) + "</td>" +
"<td>" + _getLocalDateTime(o.date) + "</td>" +
"</tr>" +
"<tr>" +
"<td><b>Buchung:</b></td>" +
"<td class='clickable' onclick='showReservationDetails(" + o.reservation.id + ");'><b>Nr.:</b> " + o.reservation.id + "<br /><b>Bezeichnung:</b> " + o.reservation.subject + "<br /><b>Buchender:</b> " + o.reservation.contact.name + "<br /><b>Raum:</b> " + o.reservation.room.longname + "<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br /><b>Von:</b> " + _getLocalDateTime(moment(o.reservation.preparation.from)._d) + "<br /><b>Bis:</b> " + _getLocalDateTime(moment(o.reservation.preparation.to)._d) + "<br /><br /><b>Zeitraum Veranstaltung:</b><br /><b>Von:</b> " + _getLocalDateTime(moment(o.reservation.event.from)._d) + "<br /><b>Bis:</b> " + _getLocalDateTime(moment(o.reservation.event.to)._d) + "<br /><br /><span style='font-size: 80%;'>Anklicken für Details</span></td>" +
"<td class='clickable' onclick='showReservationDetails(" + o.reservation.id + ");'><b>Nr.:</b> " + o.reservation.id + "<br /><b>Bezeichnung:</b> " + o.reservation.subject + "<br /><b>Buchender:</b> " + o.reservation.contact.name + "<br /><b>Raum:</b> " + o.reservation.room.longname + "<br /><br /><b>Zeitraum inkl. Auf- und Abbau:</b><br /><b>Von:</b> " + _getLocalDateTime(o.reservation.preparation.from) + "<br /><b>Bis:</b> " + _getLocalDateTime(o.reservation.preparation.to) + "<br /><br /><b>Zeitraum Veranstaltung:</b><br /><b>Von:</b> " + _getLocalDateTime(o.reservation.event.from) + "<br /><b>Bis:</b> " + _getLocalDateTime(o.reservation.event.to) + "<br /><br /><span style='font-size: 80%;'>Anklicken für Details</span></td>" +
"</tr>" +
"<tr>" +
"<td><b>Grund:</b></td>" +
......
......@@ -151,20 +151,20 @@ function refreshReservations() {
if (! _.isEqual(r.content, _reservations) || forceReload) {
if (r.content) {
_reservations.all = r.content;
_reservations.open.upcoming = $.grep(_reservations.all, (r, i) => r.confirmed === 0 && r.denied === 0 && moment(_validateDate(r.preparation.to, 'YYYY-MM-DD HH:mm') ? r.preparation.to : r.event.to)._d >= now);
_reservations.open.upcoming = $.grep(_reservations.all, (r, i) => r.confirmed === 0 && r.denied === 0 && dayjs(_validateDate(r.preparation.to, 'YYYY-MM-DD HH:mm') ? r.preparation.to : r.event.to) >= now);
_reservations.open.total = $.grep(_reservations.all, (r, i) => r.confirmed === 0 && r.denied === 0);
_reservations.confirmed.upcoming = $.grep(_reservations.all, (r, i) => r.confirmed === 1 && moment(_validateDate(r.preparation.to, 'YYYY-MM-DD HH:mm') ? r.preparation.to : r.event.to)._d >= now);
_reservations.confirmed.upcoming = $.grep(_reservations.all, (r, i) => r.confirmed === 1 && dayjs(_validateDate(r.preparation.to, 'YYYY-MM-DD HH:mm') ? r.preparation.to : r.event.to) >= now);
_reservations.confirmed.total = $.grep(_reservations.all, (r, i) => r.confirmed === 1);
_reservations.denied.upcoming = $.grep(_reservations.all, (r, i) => r.denied === 1 && moment(_validateDate(r.preparation.to, 'YYYY-MM-DD HH:mm') ? r.preparation.to : r.event.to)._d >= now);
_reservations.denied.upcoming = $.grep(_reservations.all, (r, i) => r.denied === 1 && dayjs(_validateDate(r.preparation.to, 'YYYY-MM-DD HH:mm') ? r.preparation.to : r.event.to) >= now);
_reservations.denied.total = $.grep(_reservations.all, (r, i) => r.denied === 1);
_reservations.archived = $.grep(_reservations.all, (r, i) => moment(_validateDate(r.preparation.to, 'YYYY-MM-DD HH:mm') ? r.preparation.to : r.event.to)._d <= now);
_reservations.current = $.grep(_reservations.all, (r, i) => moment(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from)._d <= now && moment(_validateDate(r.preparation.to, 'YYYY-MM-DD HH:mm') ? r.preparation.to : r.event.to)._d >= now);
_reservations.upcoming.total = $.grep(_reservations.all, (r, i) => moment(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from)._d >= now);
_reservations.upcoming.month6 = $.grep(_reservations.upcoming.total, (r, i) => moment(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from)._d <= _addDays(now, 180));
_reservations.upcoming.month3 = $.grep(_reservations.upcoming.month6, (r, i) => moment(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from)._d <= _addDays(now, 90));
_reservations.upcoming.month1 = $.grep(_reservations.upcoming.month3, (r, i) => moment(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from)._d <= _addDays(now, 30));
_reservations.upcoming.week2 = $.grep(_reservations.upcoming.month1, (r, i) => moment(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from)._d <= _addDays(now, 14));
_reservations.upcoming.week1 = $.grep(_reservations.upcoming.week2, (r, i) => moment(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from)._d <= _addDays(now, 7));
_reservations.archived = $.grep(_reservations.all, (r, i) => dayjs(_validateDate(r.preparation.to, 'YYYY-MM-DD HH:mm') ? r.preparation.to : r.event.to) <= now);
_reservations.current = $.grep(_reservations.all, (r, i) => dayjs(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from) <= now && dayjs(_validateDate(r.preparation.to, 'YYYY-MM-DD HH:mm') ? r.preparation.to : r.event.to) >= now);
_reservations.upcoming.total = $.grep(_reservations.all, (r, i) => dayjs(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from)now);
_reservations.upcoming.month6 = $.grep(_reservations.upcoming.total, (r, i) => dayjs(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from)(now, 180));
_reservations.upcoming.month3 = $.grep(_reservations.upcoming.month6, (r, i) => dayjs(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from)Days(now, 90));
_reservations.upcoming.month1 = $.grep(_reservations.upcoming.month3, (r, i) => dayjs(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from) <= _addDays(now, 30));
_reservations.upcoming.week2 = $.grep(_reservations.upcoming.month1, (r, i) => dayjs(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from) <= _addDays(now, 14));
_reservations.upcoming.week1 = $.grep(_reservations.upcoming.week2, (r, i) => dayjs(_validateDate(r.preparation.from, 'YYYY-MM-DD HH:mm') ? r.preparation.from : r.event.from) <= _addDays(now, 7));
_reservations.lernsprint = $.grep(_reservations.all, (r, i) => r.room.room_type === 1);
_reservations.studyspace = $.grep(_reservations.all, (r, i) => r.room.room_type === 5);
} else {
......@@ -222,8 +222,8 @@ function refreshOffenses() {
if (_currentTab === "#offenses_page") {
_offenders = [];
const today = new Date();
const sixmonthsago = moment(today).setMonth(today.getMonth() - 6);
const yearago = moment(today).setFullYear(today.getFullYear() - 1);
const sixmonthsago = dayjs().subtract(6, 'months');
const yearago = dayjs().subtract(1, 'years');
$.each(_offenses, (i, offense) => {
let offender_index = -1;
let filter = $.grep(_offenders, (offender, j) => { if (offender.name === offense.offender.name) { offender_index = j; return true; } return false; });
......@@ -243,10 +243,10 @@ function refreshOffenses() {
offender.offenses_12m = 0;
$.each(offender.offenses, (j, offense) => {
if (moment(offense.date)._d > yearago) {
if (dayjs(offense.date) > yearago) {
offender.offenses_12m++;
}
if (moment(offense.date)._d > sixmonthsago) {
if (dayjs(offense.date) > sixmonthsago) {
offender.offenses_6m++;
}
});
......
......@@ -425,12 +425,12 @@ function changeReservationTimes(fieldorid) {
text: "Zeiten speichern",
click: () => {
if (
moment(from_event)._d < moment(to_event)._d &&
dayjs(from_event) < dayjs(to_event) &&
(
reservation.room.room_type === 1 || (
moment(from_preparation)._d <= moment(from_event)._d &&
moment(to_preparation)._d >= moment(to_event)._d &&
moment(from_preparation)._d < moment(to_preparation)._d
dayjs(from_preparation) <= dayjs(from_event) &&
dayjs(to_preparation) >= dayjs(to_event) &&
dayjs(from_preparation) < dayjs(to_preparation)
)
)
) {
......@@ -505,7 +505,7 @@ function addReservation() {
to_preparation = "studyspace";
to_event = _addDays(from_event, 6);
to_event = _getFormattedDateTime(moment(to_event).set({"hour": 22, "minute": 0}));
to_event = _getFormattedDateTime(dayjs(to_event).set('hours', 22).set('minutes', 0));
}
showDialog({
......@@ -675,11 +675,11 @@ function showReservationDetails(fieldorid) {
(reservation.room.room_type === 1 ? "<b>Lernsprint:</b> " + reservation.ls_intentions + "<br />" : "") +
"<br />" +
((reservation.room.room_type !== 1 && reservation.room.room_type !== 5) ? "<b>Zeitraum inkl. An- und Abbau:</b><br />" +
"<b>Von:</b> " + _getLocalDateTime(moment(reservation.preparation.from)._d) + "<br />" +
"<b>Bis:</b> " + _getLocalDateTime(moment(reservation.preparation.to)._d) + "<br /><br />" : "") +
"<b>Von:</b> " + _getLocalDateTime(reservation.preparation.from) + "<br />" +
"<b>Bis:</b> " + _getLocalDateTime(reservation.preparation.to) + "<br /><br />" : "") +
"<b>Zeitraum " + (reservation.room.room_type === 1 ? 'Lernsprint' : (reservation.room_type === 5 ? 'Study Space' : 'Veranstaltung')) + ":</b><br />" +
"<b>Von:</b> " + _getLocalDateTime(moment(reservation.event.from)._d) + "<br />" +
"<b>Bis:</b> " + _getLocalDateTime(moment(reservation.event.to)._d) + "<br /><br />" +
"<b>Von:</b> " + _getLocalDateTime(reservation.event.from) + "<br />" +
"<b>Bis:</b> " + _getLocalDateTime(reservation.event.to) + "<br /><br />" +
"<b>Kontakt:</b><br />" +
"👤 " + reservation.contact.name + "<br />" +
"📧 <a href='mailto:" + reservation.contact.email + "?subject=[AStA Raumbuchung] Ihre AStA Raumbuchung'>" + reservation.contact.email + "</a><br />" +
......@@ -688,8 +688,8 @@ function showReservationDetails(fieldorid) {
"<br /><br />" +
"<b>Beschreibung:</b> <span class='resv_comment'>" + reservation.comments.user + "</span><br /><br />" +
"<b>Backendkommentar:</b> <span class='resv_editorcomment'>" + editorcomment + "</span><br /><br />" +
"<b>Buchung eingegangen:</b> " + _getLocalDateTime(moment(reservation.creation)._d) + "<br />" +
"<b>Zuletzt geändert:</b> " + _getLocalDateTime(moment(reservation.lastchange)._d) + "<br /><br />" +
"<b>Buchung eingegangen:</b> " + _getLocalDateTime(reservation.creation) + "<br />" +
"<b>Zuletzt geändert:</b> " + _getLocalDateTime(reservation.lastchange) + "<br /><br />" +
refreshments,
title: reservation.denied === 1 ? "Abgelehnte Buchung" : (reservation.confirmed === 0 ? "Unbestätigte Buchung" : "Bestätigte Buchung"),
position: {
......
......@@ -26,7 +26,7 @@
* @returns {String} - Given date in "YYYY-MM-DD" ("year-month-day") format
*/
function _getFormattedDate(d) {
return moment(d).format("YYYY-MM-DD");
return dayjs(d).format("YYYY-MM-DD");
}
/**
......@@ -36,7 +36,7 @@ function _getFormattedDate(d) {
* @returns {String} - Given date in "HH:mm" ("hour:minute") format
*/
function _getFormattedTime(d) {
return moment(d).format("HH:mm");
return dayjs(d).format("HH:mm");
}
/**
......@@ -46,7 +46,7 @@ function _getFormattedTime(d) {
* @returns {String} - Given date in "YYYY-MM-DD hh:mm" ("year-month-day hour:minute", 24h) format
*/
function _getFormattedDateTime(d) {
return moment(d).format("YYYY-MM-DD HH:mm");
return dayjs(d).format("YYYY-MM-DD HH:mm");
}
/**
......@@ -56,7 +56,7 @@ function _getFormattedDateTime(d) {
* @returns {String} - Given date in "W, DD.MM.YYYY, hh:mm Uhr" ("weekday, day.month.year, hour:minute Uhr") format
*/
function _getLocalDateTime(d) {
return moment(d).locale("de").format("dddd, DD.MM.YYYY, HH:mm") + " Uhr";
return dayjs(d).locale("de").format("dddd, DD.MM.YYYY, HH:mm") + " Uhr";
}
/**
......@@ -66,7 +66,7 @@ function _getLocalDateTime(d) {
* @returns {String} - Given date in "DD.MM.YYYY" ("day.month.year") format
*/
function _getLocalDate(d) {
return moment(d).locale("de").format("DD.MM.YYYY");
return dayjs(d).locale("de").format("DD.MM.YYYY");
}
/**
......@@ -76,7 +76,7 @@ function _getLocalDate(d) {
* @returns {String} - Given date in "w, DD.MM., hh:mm Uhr" ("short weekday, day.month.year, hour:minute Uhr") format
*/
function _getLocalDateTimeShort(d) {
return moment(d).locale("de").format("dd., DD.MM.YYYY, HH:mm") + " Uhr";
return dayjs(d).locale("de").format("dd., DD.MM.YYYY, HH:mm") + " Uhr";
}
/**
......@@ -86,7 +86,7 @@ function _getLocalDateTimeShort(d) {
* @returns {String} - Given date in "YYYYMMDDhhmmss" ("yearmonthdayhourminutesecond") format
*/
function _getTimestamp(d) {
return moment(d).format("YYYYMMDDHHmmss");
return dayjs(d).format("YYYYMMDDHHmmss");
}
/**
......@@ -97,7 +97,7 @@ function _getTimestamp(d) {
* @returns {Date} - Given date with given number of days added
*/
function _addDays(date, days) {
return moment(date).add(days, "days");
return dayjs(date).add(days, "days");
}
/**
......@@ -108,7 +108,7 @@ function _addDays(date, days) {
* @returns {Date} - Given date with given number of hours added
*/
function _addHours(date, hours) {
return moment(date).add(hours, "hours");
return dayjs(date).add(hours, "hours");
}
/**
......@@ -151,7 +151,7 @@ function _validateEmail(email) {
function _validateDate(datestring) {
const format = arguments.length > 1 && arguments[1] !== undefined && typeof arguments[1] === "string" ? arguments[1] : 'YYYY-MM-DD HH:mm:ss';
return moment(datestring, format, true).isValid();
return dayjs(datestring, format, true).isValid();
}
/**
......
......@@ -94,22 +94,27 @@
"integrity": "sha512-XkZfj0ROhem0Zdv44+LF15COsYmxnqL7Wd/gvwuWAauYoALbt2x94b6dIKF9fB6SIyOMYEQngA82t9RnC6b/aw=="
},
"datatables.net": {
"version": "1.10.21",
"resolved": "https://registry.npmjs.org/datatables.net/-/datatables.net-1.10.21.tgz",
"integrity": "sha512-/bSZtxmf3GTpYcvEmwZ8q26I1yhSx8qklR2B+s1K8+/51UW/zc2zTYwJMqr/Z+iCYixAc00ildj4g2x0Qamolw==",
"version": "1.10.22",
"resolved": "https://registry.npmjs.org/datatables.net/-/datatables.net-1.10.22.tgz",
"integrity": "sha512-ujn8GvkQIBYzYH54XY7OrI0Zb35TKRd9ABYfbnXgBfwTGIFT6UsmXrfHU5Yk+MSDoF0sDu2TB+31V6c+zUZ0Pw==",
"requires": {
"jquery": ">=1.7"
}
},
"datatables.net-dt": {
"version": "1.10.21",
"resolved": "https://registry.npmjs.org/datatables.net-dt/-/datatables.net-dt-1.10.21.tgz",
"integrity": "sha512-P89PgkhVCB6shP0CbigmB1Z812yfdfhvAbUdg08mLuF7tuvLFPQC9F+WIV30Hj9mgMsPALWAEJEYAA3aJjuqIA==",
"version": "1.10.22",
"resolved": "https://registry.npmjs.org/datatables.net-dt/-/datatables.net-dt-1.10.22.tgz",
"integrity": "sha512-JYqE8noge7YGOydsiyLsWtPUofOHFEMCeOwS47kpykWqDJyU6GE2E3JaEeDq6hokg39UQKDNIRFnsM7GhA/BGw==",
"requires": {
"datatables.net": "1.10.21",
"datatables.net": "1.10.22",
"jquery": ">=1.7"
}
},
"dayjs": {
"version": "1.8.36",
"resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.8.36.tgz",
"integrity": "sha512-3VmRXEtw7RZKAf+4Tv1Ym9AGeo8r8+CjDi26x+7SYQil1UqtqdaokhzoEJohqlzt0m5kacJSDhJQkG/LWhpRBw=="
},
"he": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
......@@ -151,14 +156,14 @@
"integrity": "sha1-CaFa4HZroL6xkAwnwewxnvLkVj4="
},
"ua-parser-js": {
"version": "0.7.21",
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.21.tgz",
"integrity": "sha512-+O8/qh/Qj8CgC6eYBVBykMrNtp5Gebn4dlGD/kKXVkJNDwyrAwSIqwz8CDf+tsAIWVycKcku6gIXJ0qwx/ZXaQ=="
"version": "0.7.22",
"resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-0.7.22.tgz",
"integrity": "sha512-YUxzMjJ5T71w6a8WWVcMGM6YWOTX27rCoIQgLXiWaxqXSx9D7DNjiGWn1aJIRSQ5qr0xuhra77bSIh6voR/46Q=="
},
"underscore": {
"version": "1.10.2",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.10.2.tgz",
"integrity": "sha512-N4P+Q/BuyuEKFJ43B9gYuOj4TQUHXX+j2FqguVOpjkssLUUrnJofCcBccJSCoeturDoZU6GorDTHSvUDlSQbTg=="
"version": "1.11.0",
"resolved": "https://registry.npmjs.org/underscore/-/underscore-1.11.0.tgz",
"integrity": "sha512-xY96SsN3NA461qIRKZ/+qox37YXPtSBswMGfiNptr+wrt6ds4HaMw23TP612fEyGekRE6LNRiLYr/aqbHXNedw=="
}
}
}