Commit 3c354e02 authored by Michael Koch's avatar Michael Koch
Browse files

`moment(...)._d` is only needed when parsing timestamp strings, not for general Date creation.

parent 7fc944f7
......@@ -56,7 +56,7 @@ function setupMapTooltip() {
* Initialize frontend
*/
function setupFrontend() {
const today = moment()._d;
const today = new Date();
_currentTab = "#frontend";
$(".resv_time").each((i, e) => e.placeholder = _getFormattedDate(today) + " " + e.getAttribute("placeholder_time"));
......@@ -112,7 +112,7 @@ function detectRoomSelection() {
}
$("#frontend_row_times_preparation").hide();
$("#frontend_row_contact_web").hide();
$("#new_reservation_from_event").datetimepicker({ minDate: _getFormattedDate(_addDays(moment()._d, 7)), timepicker: false, defaultTime: '7:00' });
$("#new_reservation_from_event").datetimepicker({ minDate: _getFormattedDate(_addDays(new Date(), 7)), timepicker: false, defaultTime: '7:00' });
if (r_type === 5) {
$("#frontend_row_ls_intentions").hide();
$("#frontend_row_lernsprint_info").hide();
......@@ -131,7 +131,7 @@ function detectRoomSelection() {
$("#new_reservation_from_event").addClass("long");
$("#new_reservation_from_event").datetimepicker({ disabledWeekDays: [] });
$("#new_reservation_to_event").show();
$("#new_reservation_to_event").datetimepicker({ minDate: _getFormattedDate(_addDays(moment()._d, 7)), timepicker: false, defaultTime: '22:00', disabledWeekDays: [] });
$("#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);
......@@ -139,7 +139,7 @@ function detectRoomSelection() {
$("#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(moment()._d, 1)]));
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);
$("#new_reservation_from_event").datetimepicker({ minDate: minD, maxDate: maxD });
}
......@@ -342,7 +342,7 @@ function checkNewReservationForm() {
* Sets one week limits on datetime pickers
*/
function limitFrontendDatetimePicker() {
const tomorrow = _addDays(moment()._d, 1);
const tomorrow = _addDays(new Date(), 1);
let fp = $("#new_reservation_from_preparation");
let tp = $("#new_reservation_to_preparation");
......
......@@ -29,7 +29,7 @@ function setupLandingGraph() {
const newReservations = [];
const weekdayShort = ["So", "Mo", "Di", "Mi", "Do", "Fr", "Sa"];
const numdays = 7;
let date = moment()._d;
let date = new Date();
date.setDate(date.getDate() - (numdays + 1));
function iterate_dates(count) {
......
......@@ -90,7 +90,7 @@ function showNewOffense() {
"</tr>" +
"<tr>" +
"<td><b>Datum, Uhrzeit:</b></td>" +
"<td><input type='text' class='longer' id='new_offense_date' placeholder='JJJJ-MM-TT hh:mm:ss' value='" + _getFormattedDateTime(moment()._d) + "'></td>" +
"<td><input type='text' class='longer' id='new_offense_date' placeholder='JJJJ-MM-TT hh:mm:ss' value='" + _getFormattedDateTime(new Date()) + "'></td>" +
"</tr>" +
"<tr>" +
"<td><b>Grund:</b></td>" +
......@@ -123,7 +123,7 @@ function showNewOffense() {
},
auto: false
});
$("#new_offense_date").datetimepicker(_.extend(JSON.parse(JSON.stringify(_defaults_datetimepicker)), {'minDate': _getFormattedDateTime(_addDays(moment()._d, -730)), 'defaultDate': _getFormattedDateTime(moment()._d)}));
$("#new_offense_date").datetimepicker(_.extend(JSON.parse(JSON.stringify(_defaults_datetimepicker)), {'minDate': _getFormattedDateTime(_addDays(new Date(), -730)), 'defaultDate': _getFormattedDateTime(new Date())}));
let offender_string = "";
const offense_reservations = _.sortBy(_reservations.archived, (r) => { return r.preparation.from; }).reverse();
......
......@@ -42,7 +42,7 @@ function refreshUsers() {
"locked": 0,
"current_token": _loggedInUser.current_token,
"tokens": _loggedInUser.tokens,
"lastchange": _getFormattedDateTimeSeconds(moment()._d)
"lastchange": _getFormattedDateTimeSeconds(new Date())
}];
}
......@@ -144,7 +144,7 @@ function refreshRooms() {
function refreshReservations() {
const callback = (arguments.length > 0 && arguments[0] !== undefined && arguments[0] !== null && typeof arguments[0] === "function") ? arguments[0] : (r) => {};
const forceReload = arguments.length > 1 && arguments[1] !== undefined && arguments[1] !== null && typeof arguments[1] === "boolean" ? arguments[1] : false;
const now = moment()._d;
const now = new Date();
_callBackend({ "cmd": "getReservations" }, (r) => {
if (r.result === "success") {
......@@ -221,7 +221,7 @@ function refreshOffenses() {
if (_currentTab === "#offenses_page") {
_offenders = [];
const today = moment()._d;
const today = new Date();
const sixmonthsago = moment(today).setMonth(today.getMonth() - 6);
const yearago = moment(today).setFullYear(today.getFullYear() - 1);
$.each(_offenses, (i, offense) => {
......@@ -282,7 +282,7 @@ function refreshUpcomingReservations() {
const callback = (arguments.length > 0 && arguments[0] !== undefined && arguments[0] !== null && typeof arguments[0] === "function") ? arguments[0] : (r) => {};
const forceReload = arguments.length > 1 && arguments[1] !== undefined && arguments[1] !== null && typeof arguments[1] === "boolean" ? arguments[1] : false;
_callBackend({ "cmd": "getReservationsFiltered", "from_preparation_before": _getFormattedDateTime(_addDays(moment()._d, 7)), "from_preparation_after": _getFormattedDateTime(moment()._d) }, (r) => {
_callBackend({ "cmd": "getReservationsFiltered", "from_preparation_before": _getFormattedDateTime(_addDays(new Date(), 7)), "from_preparation_after": _getFormattedDateTime(new Date()) }, (r) => {
if (r.result === "success") {
if (r.content) {
if (! _.isEqual(r.content, _reservations.upcoming.week1) || forceReload) {
......@@ -291,7 +291,7 @@ function refreshUpcomingReservations() {
} else {
_reservations.upcoming.week1 = [];
}
_callBackend({ "cmd": "getReservationsFiltered", "from_preparation_before": _getFormattedDateTime(_addDays(moment()._d, 14)), "from_preparation_after": _getFormattedDateTime(moment()._d) }, (r) => {
_callBackend({ "cmd": "getReservationsFiltered", "from_preparation_before": _getFormattedDateTime(_addDays(new Date(), 14)), "from_preparation_after": _getFormattedDateTime(new Date()) }, (r) => {
if (r.result === "success") {
if (r.content) {
if (! _.isEqual(r.content, _reservations.upcoming.week2) || forceReload) {
......@@ -300,7 +300,7 @@ function refreshUpcomingReservations() {
} else {
_reservations.upcoming.week2 = [];
}
_callBackend({ "cmd": "getReservationsFiltered", "from_preparation_before": _getFormattedDateTime(_addDays(moment()._d, 30)), "from_preparation_after": _getFormattedDateTime(moment()._d) }, (r) => {
_callBackend({ "cmd": "getReservationsFiltered", "from_preparation_before": _getFormattedDateTime(_addDays(new Date(), 30)), "from_preparation_after": _getFormattedDateTime(new Date()) }, (r) => {
if (r.result === "success") {
if (r.content) {
if (! _.isEqual(r.content, _reservations.upcoming.month1) || forceReload) {
......@@ -309,7 +309,7 @@ function refreshUpcomingReservations() {
} else {
_reservations.upcoming.month1 = [];
}
_callBackend({ "cmd": "getReservationsFiltered", "from_preparation_before": _getFormattedDateTime(_addDays(moment()._d, 90)), "from_preparation_after": _getFormattedDateTime(moment()._d) }, (r) => {
_callBackend({ "cmd": "getReservationsFiltered", "from_preparation_before": _getFormattedDateTime(_addDays(new Date(), 90)), "from_preparation_after": _getFormattedDateTime(new Date()) }, (r) => {
if (r.result === "success") {
if (r.content) {
if (! _.isEqual(r.content, _reservations.upcoming.month3) || forceReload) {
......@@ -318,7 +318,7 @@ function refreshUpcomingReservations() {
} else {
_reservations.upcoming.month3 = [];
}
_callBackend({ "cmd": "getReservationsFiltered", "from_preparation_before": _getFormattedDateTime(_addDays(moment()._d, 180)), "from_preparation_after": _getFormattedDateTime(moment()._d) }, (r) => {
_callBackend({ "cmd": "getReservationsFiltered", "from_preparation_before": _getFormattedDateTime(_addDays(new Date(), 180)), "from_preparation_after": _getFormattedDateTime(new Date()) }, (r) => {
if (r.result === "success") {
if (r.content) {
if (! _.isEqual(r.content, _reservations.upcoming.month6) || forceReload) {
......@@ -327,7 +327,7 @@ function refreshUpcomingReservations() {
} else {
_reservations.upcoming.month6 = [];
}
_callBackend({ "cmd": "getReservationsFiltered", "from_preparation_after": _getFormattedDateTime(moment()._d) }, (r) => {
_callBackend({ "cmd": "getReservationsFiltered", "from_preparation_after": _getFormattedDateTime(new Date()) }, (r) => {
if (r.result === "success") {
if (r.content) {
if (! _.isEqual(r.content, _reservations.upcoming.total) || forceReload) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment