105 lines
2.8 KiB
JavaScript
105 lines
2.8 KiB
JavaScript
function makeAjaxCall(pType, pUrl, pSuccess, pData, pComplete) {
|
|
$.ajax({
|
|
type: pType,
|
|
url: pUrl,
|
|
data: pData,
|
|
success: pSuccess,
|
|
error: showAjaxError,
|
|
complete: pComplete
|
|
});
|
|
}
|
|
|
|
function getDateTimeStringWithLeadingZeros(pDate) {
|
|
const dateStr = getDateStringWithLeadingZeros(pDate);
|
|
|
|
const hh = (pDate.getHours() < 10 ? "0" : "") + pDate.getHours();
|
|
const m = (pDate.getMinutes() < 10 ? "0" : "") + pDate.getMinutes();
|
|
const ss = (pDate.getSeconds() < 10 ? "0" : "") + pDate.getSeconds();
|
|
|
|
return dateStr + " " + hh + ":" + m + ":" + ss;
|
|
}
|
|
|
|
function getDateStringWithLeadingZeros(pDate) {
|
|
const dd = (pDate.getDate() < 10 ? "0" : "") + pDate.getDate().toString();
|
|
const mm = ((pDate.getMonth() + 1) < 10 ? "0" : "") + (pDate.getMonth() + 1);
|
|
const yyyy = pDate.getFullYear();
|
|
|
|
return dd + "." + mm + "." + yyyy;
|
|
}
|
|
|
|
function subtractDates(date1, date2) {
|
|
const t1 = date1.getTime();
|
|
const t2 = date2.getTime();
|
|
const diff = (t2 - t1) / 60000;
|
|
|
|
return Math.abs(diff);
|
|
}
|
|
|
|
function addMinutes(date, minutes) {
|
|
return new Date(date.getTime() + minutes * 60000);
|
|
}
|
|
|
|
function stringToTime(str) {
|
|
const defaultResult = [-1, -1];
|
|
|
|
str = str.replace(":", "");
|
|
str = str.replace(".", "");
|
|
str = str.replace(" ", "");
|
|
|
|
if (str.length < 3) {
|
|
if (str.length < 2) {
|
|
str = `0${str}`;
|
|
}
|
|
while (str.length < 4) {
|
|
str = str + "0";
|
|
}
|
|
} else {
|
|
while (str.length < 4) {
|
|
str = `0${str}`;
|
|
}
|
|
}
|
|
|
|
const minutes = str.slice(2, 4);
|
|
const hours = str.slice(0, 2);
|
|
|
|
defaultResult[0] = parseInt(hours);
|
|
defaultResult[1] = parseInt(minutes);
|
|
|
|
return defaultResult;
|
|
}
|
|
|
|
function getHoursAndMinutesWithLeadingZeros(pDate) {
|
|
const hours = pDate.getHours();
|
|
const minutes = pDate.getMinutes();
|
|
|
|
const hoursString = hours < 10 ? `0${hours.toString()}` : hours.toString();
|
|
const minutesString = minutes < 10 ? `0${minutes.toString()}` : minutes.toString();
|
|
|
|
return hoursString + ":" + minutesString;
|
|
}
|
|
|
|
function toShortDateString(dateString, trennzeichen) {
|
|
const geteilt = dateString.split(trennzeichen);
|
|
var yyyy = "";
|
|
const mm = geteilt[1];
|
|
const dd = geteilt[0];
|
|
|
|
for (let i = 0; i < 4 - geteilt[2].split(" ")[0].length; i++) {
|
|
yyyy += "0";
|
|
}
|
|
|
|
yyyy += geteilt[2].split(" ")[0];
|
|
|
|
return (dd < 10 ? "0" : "") + dd + "." + (mm < 10 ? "0" : "") + mm + "." + yyyy;
|
|
}
|
|
|
|
function toDateStringYearMonthDay(pDate) {
|
|
const dd2 = pDate.getDate();
|
|
const mm2 = pDate.getMonth() + 1;
|
|
const yyyy2 = pDate.getFullYear();
|
|
|
|
const ddStr2 = dd2 < 10 ? "0" + dd2 : dd2;
|
|
const mmStr2 = mm2 < 10 ? "0" + mm2 : mm2;
|
|
|
|
return yyyy2 + "-" + mmStr2 + "-" + ddStr2;
|
|
} |