Compare commits
11
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
dd6f08880a | ||
|
|
b3fb3b1b8f | ||
|
|
dc20f35fb8 | ||
|
|
9024dbc26e | ||
|
|
05a6a3ee23 | ||
|
|
c9f3efd7f9 | ||
|
|
7983e23815 | ||
|
|
5446b2d1cb | ||
|
|
8205b7d9d9 | ||
|
|
53ac8ff0bf | ||
|
|
e436e61041 |
No files matched your search
Generated
-12
@@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module type="WEB_MODULE" version="4">
|
|
||||||
<component name="NewModuleRootManager">
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/.tmp" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/temp" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/tmp" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
<component name="InspectionProjectProfileManager">
|
|
||||||
<profile version="1.0">
|
|
||||||
<option name="myName" value="Project Default" />
|
|
||||||
<inspection_tool class="CssUnknownProperty" enabled="true" level="WARNING" enabled_by_default="true">
|
|
||||||
<option name="myCustomPropertiesEnabled" value="true" />
|
|
||||||
<option name="myIgnoreVendorSpecificProperties" value="false" />
|
|
||||||
<option name="myCustomPropertiesList">
|
|
||||||
<value>
|
|
||||||
<list size="1">
|
|
||||||
<item index="0" class="java.lang.String" itemvalue="font-color" />
|
|
||||||
</list>
|
|
||||||
</value>
|
|
||||||
</option>
|
|
||||||
</inspection_tool>
|
|
||||||
</profile>
|
|
||||||
</component>
|
|
||||||
Generated
-6
@@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="JavaScriptLibraryMappings">
|
|
||||||
<includedPredefinedLibrary name="Node.js Core" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
Generated
-8
@@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/.idea/anwendungsprojekt.iml" filepath="$PROJECT_DIR$/.idea/anwendungsprojekt.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 30 KiB |
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
Before Width: | Height: | Size: 8.4 MiB |
Binary file not shown.
|
Before Width: | Height: | Size: 2.1 MiB |
@@ -1,4 +0,0 @@
|
|||||||
# TIF22A_AnwProjekt_B
|
|
||||||
Team B im Anwendungsprojekt (TIF22A)
|
|
||||||
|
|
||||||
Website can be accessed under: http://lectureplanner.de/ (caution no https, only http)
|
|
||||||
-5
@@ -1,5 +0,0 @@
|
|||||||
<component name="ProjectCodeStyleConfiguration">
|
|
||||||
<state>
|
|
||||||
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default" />
|
|
||||||
</state>
|
|
||||||
</component>
|
|
||||||
Generated
+9
@@ -9,6 +9,7 @@
|
|||||||
"version": "0.1.0",
|
"version": "0.1.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"autoprefixer": "10.4.14",
|
"autoprefixer": "10.4.14",
|
||||||
|
"feiertagejs": "^1.3.9",
|
||||||
"next": "13.3.4",
|
"next": "13.3.4",
|
||||||
"postcss": "8.4.23",
|
"postcss": "8.4.23",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
@@ -530,6 +531,14 @@
|
|||||||
"reusify": "^1.0.4"
|
"reusify": "^1.0.4"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/feiertagejs": {
|
||||||
|
"version": "1.3.9",
|
||||||
|
"resolved": "https://registry.npmjs.org/feiertagejs/-/feiertagejs-1.3.9.tgz",
|
||||||
|
"integrity": "sha512-tUP+WBv2OWBhPwe3NfqwCtjMq+ym598a42tfqmL0FySswEb9xs96p2iKwqqx+lxKieu1njJBRZKsFm92bJhxZw==",
|
||||||
|
"engines": {
|
||||||
|
"node": ">=8.0.0"
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/fill-range": {
|
"node_modules/fill-range": {
|
||||||
"version": "7.0.1",
|
"version": "7.0.1",
|
||||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"autoprefixer": "10.4.14",
|
"autoprefixer": "10.4.14",
|
||||||
|
"feiertagejs": "^1.3.9",
|
||||||
"next": "13.3.4",
|
"next": "13.3.4",
|
||||||
"postcss": "8.4.23",
|
"postcss": "8.4.23",
|
||||||
"react": "18.2.0",
|
"react": "18.2.0",
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ import {baseURL} from "@/components/Constants";
|
|||||||
import {ErrorType} from "@/components/ErrorType";
|
import {ErrorType} from "@/components/ErrorType";
|
||||||
import BasicDateCalendar from "@/components/CalendarSideBar";
|
import BasicDateCalendar from "@/components/CalendarSideBar";
|
||||||
import feiertagejs from "feiertagejs";
|
import feiertagejs from "feiertagejs";
|
||||||
|
import PopUp from "@/components/PopUp";
|
||||||
|
import {useRouter} from "next/router";
|
||||||
|
|
||||||
let cellHeight = 20;
|
let cellHeight = 20;
|
||||||
|
|
||||||
@@ -19,6 +21,8 @@ let currentYear;
|
|||||||
let semesterStartYear;
|
let semesterStartYear;
|
||||||
let semesterEndYear;
|
let semesterEndYear;
|
||||||
let selectedElement;
|
let selectedElement;
|
||||||
|
let lastEndTimeDrag;
|
||||||
|
let lastStartTimeDrag;
|
||||||
let grabbedDown;
|
let grabbedDown;
|
||||||
|
|
||||||
let isDayOkay = [true, true, true, true, true, true]
|
let isDayOkay = [true, true, true, true, true, true]
|
||||||
@@ -26,6 +30,8 @@ let isDayOkay = [true, true, true, true, true, true]
|
|||||||
let errorState = [ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay]
|
let errorState = [ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay]
|
||||||
let grayedOut = [false, false, false, false, false, false]
|
let grayedOut = [false, false, false, false, false, false]
|
||||||
|
|
||||||
|
let timePlanned = 0
|
||||||
|
|
||||||
export default function CalenderView(p) {
|
export default function CalenderView(p) {
|
||||||
|
|
||||||
const [entries, setEntries] = useState([[], [], [], [], [], []])
|
const [entries, setEntries] = useState([[], [], [], [], [], []])
|
||||||
@@ -38,6 +44,8 @@ export default function CalenderView(p) {
|
|||||||
const [endYearCalenderSideBar, setEndYearCalenderSideBar] = useState(2000)
|
const [endYearCalenderSideBar, setEndYearCalenderSideBar] = useState(2000)
|
||||||
const [highlightMonth, setHighlightMonth] = useState(0)
|
const [highlightMonth, setHighlightMonth] = useState(0)
|
||||||
const [highlightYear, setHighlightYear] = useState(2000)
|
const [highlightYear, setHighlightYear] = useState(2000)
|
||||||
|
const [popUpToggleAbgeben, setPopUpToggleAbgeben] = useState(false)
|
||||||
|
const router = useRouter();
|
||||||
|
|
||||||
|
|
||||||
function readEntries() {
|
function readEntries() {
|
||||||
@@ -66,12 +74,10 @@ export default function CalenderView(p) {
|
|||||||
errorState[i] = ErrorType.TooLate
|
errorState[i] = ErrorType.TooLate
|
||||||
isDayOkay[i] = false
|
isDayOkay[i] = false
|
||||||
break
|
break
|
||||||
}
|
} else if (new Date(currentYear, 0, elem.daynumber).getUTCDay() === 5) {
|
||||||
else if(new Date(currentYear, 0, elem.daynumber).getUTCDay() === 5) {
|
|
||||||
errorState[i] = ErrorType.Saturday
|
errorState[i] = ErrorType.Saturday
|
||||||
isDayOkay[i] = false
|
isDayOkay[i] = false
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
if ((elem.timestart - 1) / 4 <= 11 && (elem.timeend - 1) / 4 >= 14) {
|
if ((elem.timestart - 1) / 4 <= 11 && (elem.timeend - 1) / 4 >= 14) {
|
||||||
errorState[i] = ErrorType.NotEnoughLunchTime
|
errorState[i] = ErrorType.NotEnoughLunchTime
|
||||||
isDayOkay[i] = false
|
isDayOkay[i] = false
|
||||||
@@ -111,8 +117,8 @@ export default function CalenderView(p) {
|
|||||||
for (let k = 0; k < 20; k++) {
|
for (let k = 0; k < 20; k++) {
|
||||||
if (en[i][k] != null) {
|
if (en[i][k] != null) {
|
||||||
|
|
||||||
if (en[i][k].semesterid != currentsid)
|
|
||||||
{
|
if (en[i][k].semesterid != currentsid) {
|
||||||
for (let l = 0; l < 20; l++) {
|
for (let l = 0; l < 20; l++) {
|
||||||
if (en[i][l] != null && en[i][l].usercreatedbyid != userid) {
|
if (en[i][l] != null && en[i][l].usercreatedbyid != userid) {
|
||||||
if (en[i][l].timestart <= en[i][k].timestart && en[i][l].timeend >= en[i][k].timeend) {
|
if (en[i][l].timestart <= en[i][k].timestart && en[i][l].timeend >= en[i][k].timeend) {
|
||||||
@@ -144,8 +150,7 @@ export default function CalenderView(p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let j = 0;
|
let j = 0;
|
||||||
for(let i = Math.round(((new Date(currentYear, 0, currentWeekStartDay) - new Date(currentYear, 0, 0)) / (1000 * 60 * 60 * 24))); i <= Math.round(((new Date(currentYear, 0, currentWeekStartDay + 5) - new Date(currentYear, 0, 0)) / (1000 * 60 * 60 * 24))); i++)
|
for (let i = Math.round(((new Date(currentYear, 0, currentWeekStartDay) - new Date(currentYear, 0, 0)) / (1000 * 60 * 60 * 24))); i <= Math.round(((new Date(currentYear, 0, currentWeekStartDay + 5) - new Date(currentYear, 0, 0)) / (1000 * 60 * 60 * 24))); i++) {
|
||||||
{
|
|
||||||
grayedOut[j] = i % Math.round(((new Date(currentYear, 11, 31) - new Date(currentYear, 0, 0)) / (1000 * 60 * 60 * 24))) < semesterStart && semesterEnd && new Date(currentYear, 0, currentWeekStartDay + j).getFullYear() == semesterStartYear || i % Math.round(((new Date(currentYear, 11, 31) - new Date(currentYear, 0, 0)) / (1000 * 60 * 60 * 24))) > semesterEnd && new Date(currentYear, 0, currentWeekStartDay + j).getFullYear() == semesterEndYear
|
grayedOut[j] = i % Math.round(((new Date(currentYear, 11, 31) - new Date(currentYear, 0, 0)) / (1000 * 60 * 60 * 24))) < semesterStart && semesterEnd && new Date(currentYear, 0, currentWeekStartDay + j).getFullYear() == semesterStartYear || i % Math.round(((new Date(currentYear, 11, 31) - new Date(currentYear, 0, 0)) / (1000 * 60 * 60 * 24))) > semesterEnd && new Date(currentYear, 0, currentWeekStartDay + j).getFullYear() == semesterEndYear
|
||||||
j++
|
j++
|
||||||
}
|
}
|
||||||
@@ -155,6 +160,26 @@ export default function CalenderView(p) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
setEntries(en)
|
setEntries(en)
|
||||||
|
|
||||||
|
if(localStorage.getItem("admin") == 0)
|
||||||
|
{
|
||||||
|
let entriesURL = baseURL + "/entries/all/module?sessionid=" + localStorage.getItem("sessionid") + "&moduleid=" + localStorage.getItem("moduleid")
|
||||||
|
fetch(entriesURL).then(r => r.json()).then(allEn => {
|
||||||
|
|
||||||
|
let moduleid = localStorage.getItem("moduleid")
|
||||||
|
let sum = 0
|
||||||
|
|
||||||
|
for (let j = 0; j < allEn.length; j++) {
|
||||||
|
if (allEn[j] != null && allEn[j].moduleid == moduleid) {
|
||||||
|
sum += allEn[j].timeend - allEn[j].timestart
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
sum /= 3
|
||||||
|
timePlanned = sum
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
|
|
||||||
@@ -171,7 +196,8 @@ export default function CalenderView(p) {
|
|||||||
"usercreatedbyid": localStorage.getItem("userid"),
|
"usercreatedbyid": localStorage.getItem("userid"),
|
||||||
"timestart": row,
|
"timestart": row,
|
||||||
"timeend": row + 3,
|
"timeend": row + 3,
|
||||||
"info": localStorage.getItem("currentmodulename")
|
"info": localStorage.getItem("currentmodulename"),
|
||||||
|
"moduleid": localStorage.getItem("moduleid")
|
||||||
}
|
}
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
method: "POST",
|
method: "POST",
|
||||||
@@ -229,6 +255,18 @@ export default function CalenderView(p) {
|
|||||||
let id = selectedElement.id;
|
let id = selectedElement.id;
|
||||||
|
|
||||||
if ((selectedElement.timestart - 1) / 4 >= 7 && (selectedElement.timeend - 1) / 4 <= 18) {
|
if ((selectedElement.timestart - 1) / 4 >= 7 && (selectedElement.timeend - 1) / 4 <= 18) {
|
||||||
|
|
||||||
|
let finalTimeEnd = selectedElement.timeend
|
||||||
|
let deltaTimeEnd = (selectedElement.timeend - lastEndTimeDrag) / 3
|
||||||
|
if (timePlanned + deltaTimeEnd > 20) {
|
||||||
|
finalTimeEnd -= ((timePlanned + deltaTimeEnd) - 20) * 3
|
||||||
|
}
|
||||||
|
let finalTimeStart = selectedElement.timestart
|
||||||
|
let deltaTimeStart = (lastStartTimeDrag - selectedElement.timestart) / 3
|
||||||
|
if (deltaTimeStart + timePlanned > 20) {
|
||||||
|
finalTimeStart += (timePlanned + deltaTimeStart - 20) * 3
|
||||||
|
}
|
||||||
|
|
||||||
let url = baseURL + "/entries?sessionid=" + localStorage.getItem("sessionid");
|
let url = baseURL + "/entries?sessionid=" + localStorage.getItem("sessionid");
|
||||||
let json = {
|
let json = {
|
||||||
"id": id,
|
"id": id,
|
||||||
@@ -236,9 +274,10 @@ export default function CalenderView(p) {
|
|||||||
"yearnumber": 0,
|
"yearnumber": 0,
|
||||||
"semesterid": 0,
|
"semesterid": 0,
|
||||||
"usercreatedbyid": 0,
|
"usercreatedbyid": 0,
|
||||||
"timestart": selectedElement.timestart,
|
"timestart": finalTimeStart,
|
||||||
"timeend": selectedElement.timeend,
|
"timeend": finalTimeEnd,
|
||||||
"info": ""
|
"info": "",
|
||||||
|
"moduleid": localStorage.getItem("moduleid")
|
||||||
}
|
}
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
method: "PUT",
|
method: "PUT",
|
||||||
@@ -316,22 +355,24 @@ export default function CalenderView(p) {
|
|||||||
if (!currentId.includes("grab")) {
|
if (!currentId.includes("grab")) {
|
||||||
if (!checkForElementAtRow(row + 2, currentColumnID) && !checkForElementAtRow(row + 1, currentColumnID)) {
|
if (!checkForElementAtRow(row + 2, currentColumnID) && !checkForElementAtRow(row + 1, currentColumnID)) {
|
||||||
if ((row - 1) / 4 >= 7 && (row + 2) / 4 <= 18) {
|
if ((row - 1) / 4 >= 7 && (row + 2) / 4 <= 18) {
|
||||||
if(!grayedOut[currentColumnID]) {
|
if (!grayedOut[currentColumnID] && timePlanned + 0.8 < 20) {
|
||||||
pushEntry(currentColumnID, row)
|
pushEntry(currentColumnID, row)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let parentID = parseInt(e.target.parentElement.id.replace("e", ""));
|
let parentID = parseInt(e.target.parentElement.id.replace("e", ""));
|
||||||
if (currentUserID == getElementInColumn(parentID, currentColumnID).usercreatedbyid && getElementInColumn(parentID, currentColumnID).semesterid == currentsid) {
|
if (currentUserID == getElementInColumn(parentID, currentColumnID).usercreatedbyid && getElementInColumn(parentID, currentColumnID).moduleid == localStorage.getItem("moduleid")) {
|
||||||
grabbedDown = currentId.includes("down")
|
grabbedDown = currentId.includes("down")
|
||||||
selectedElement = getElementInColumn(parentID, currentColumnID);
|
selectedElement = getElementInColumn(parentID, currentColumnID);
|
||||||
|
lastEndTimeDrag = selectedElement.timeend
|
||||||
|
lastStartTimeDrag = selectedElement.timestart
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (e.button === 2) {
|
} else if (e.button === 2) {
|
||||||
let parentID = parseInt(e.target.id.replace("e", ""));
|
let parentID = parseInt(e.target.id.replace("e", ""));
|
||||||
if (currentUserID == getElementInColumn(parentID, currentColumnID).usercreatedbyid && currentId.includes("e") && getElementInColumn(parentID, currentColumnID).semesterid == currentsid) {
|
if (currentUserID == getElementInColumn(parentID, currentColumnID).usercreatedbyid && currentId.includes("e") && getElementInColumn(parentID, currentColumnID).moduleid == localStorage.getItem("moduleid")) {
|
||||||
let id = parseInt(currentId.replace("e", ""))
|
let id = parseInt(currentId.replace("e", ""))
|
||||||
errorState[currentColumnID] = ErrorType.Okay
|
errorState[currentColumnID] = ErrorType.Okay
|
||||||
deleteEntry(id)
|
deleteEntry(id)
|
||||||
@@ -345,8 +386,7 @@ export default function CalenderView(p) {
|
|||||||
setHighlightMonth(date.getMonth())
|
setHighlightMonth(date.getMonth())
|
||||||
setHighlightYear(date.getFullYear())
|
setHighlightYear(date.getFullYear())
|
||||||
|
|
||||||
for(let i = 0; i < errorState.length; i++)
|
for (let i = 0; i < errorState.length; i++) {
|
||||||
{
|
|
||||||
errorState[i] = ErrorType.Okay
|
errorState[i] = ErrorType.Okay
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -359,21 +399,22 @@ export default function CalenderView(p) {
|
|||||||
setHighlightMonth(date.getMonth())
|
setHighlightMonth(date.getMonth())
|
||||||
setHighlightYear(date.getFullYear())
|
setHighlightYear(date.getFullYear())
|
||||||
|
|
||||||
for(let i = 0; i < errorState.length; i++)
|
for (let i = 0; i < errorState.length; i++) {
|
||||||
{
|
|
||||||
errorState[i] = ErrorType.Okay
|
errorState[i] = ErrorType.Okay
|
||||||
}
|
}
|
||||||
|
|
||||||
readEntries()
|
readEntries()
|
||||||
}
|
}
|
||||||
|
|
||||||
function getEntryColor(userCreatedByID, columnID, semesterid) {
|
function getEntryColor(userCreatedByID, columnID, semesterid, moduleid) {
|
||||||
let id = localStorage.getItem("userid");
|
let id = localStorage.getItem("userid");
|
||||||
let currentsid = localStorage.getItem("currentsid")
|
let currentsid = localStorage.getItem("currentsid")
|
||||||
|
if(localStorage.getItem("admin") == 0)
|
||||||
|
{
|
||||||
if (id == userCreatedByID) {
|
if (id == userCreatedByID) {
|
||||||
if (isDayOkay[columnID] && semesterid == currentsid) {
|
if (isDayOkay[columnID] && moduleid == localStorage.getItem("moduleid")) {
|
||||||
return "#77932b";
|
return "#77932b";
|
||||||
}else if(semesterid != currentsid){
|
} else if (moduleid != localStorage.getItem("moduleid")) {
|
||||||
return "#346991";
|
return "#346991";
|
||||||
} else {
|
} else {
|
||||||
return "#e5a10e";
|
return "#e5a10e";
|
||||||
@@ -383,26 +424,37 @@ export default function CalenderView(p) {
|
|||||||
return "#a2a2a2";
|
return "#a2a2a2";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "#a2a2a2";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function getResizeBarColor(userCreatedByID, columnID, semesterid) {
|
function getResizeBarColor(userCreatedByID, columnID, semesterid, moduleid) {
|
||||||
let id = localStorage.getItem("userid");
|
let id = localStorage.getItem("userid");
|
||||||
let currentsid = localStorage.getItem("currentsid")
|
let currentsid = localStorage.getItem("currentsid")
|
||||||
if (id == userCreatedByID) {
|
if(localStorage.getItem("admin") == 0)
|
||||||
if (isDayOkay[columnID] && currentsid == semesterid) {
|
|
||||||
return "#5a6c20";
|
|
||||||
} else if(currentsid != semesterid)
|
|
||||||
{
|
{
|
||||||
|
if (id == userCreatedByID) {
|
||||||
|
if (isDayOkay[columnID] && moduleid == localStorage.getItem("moduleid")) {
|
||||||
|
return "#5a6c20";
|
||||||
|
} else if (moduleid != localStorage.getItem("moduleid")) {
|
||||||
return "#346991"
|
return "#346991"
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
return "#c08809";
|
return "#c08809";
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return "#a2a2a2";
|
return "#a2a2a2";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return "#a2a2a2";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
setTimeout(() => {
|
||||||
semesterStart = 0;
|
semesterStart = 0;
|
||||||
semesterEnd = 0;
|
semesterEnd = 0;
|
||||||
semesterStartYear = 0;
|
semesterStartYear = 0;
|
||||||
@@ -431,6 +483,7 @@ export default function CalenderView(p) {
|
|||||||
semesterEndYear = s.endyear;
|
semesterEndYear = s.endyear;
|
||||||
setStartDayCalenderSideBar(semesterStart)
|
setStartDayCalenderSideBar(semesterStart)
|
||||||
setEndDayCalenderSideBar(s.endday)
|
setEndDayCalenderSideBar(s.endday)
|
||||||
|
|
||||||
}).then(readEntries)
|
}).then(readEntries)
|
||||||
|
|
||||||
scrollRef.current.scrollTop = 600;
|
scrollRef.current.scrollTop = 600;
|
||||||
@@ -456,6 +509,7 @@ export default function CalenderView(p) {
|
|||||||
readEntries()
|
readEntries()
|
||||||
}
|
}
|
||||||
}, 500);
|
}, 500);
|
||||||
|
}, 100)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
|
||||||
@@ -485,8 +539,7 @@ export default function CalenderView(p) {
|
|||||||
setHighlightMonth(date.getMonth())
|
setHighlightMonth(date.getMonth())
|
||||||
setHighlightYear(currentYear)
|
setHighlightYear(currentYear)
|
||||||
|
|
||||||
for(let i = 0; i < errorState.length; i++)
|
for (let i = 0; i < errorState.length; i++) {
|
||||||
{
|
|
||||||
errorState[i] = ErrorType.Okay
|
errorState[i] = ErrorType.Okay
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -495,6 +548,29 @@ export default function CalenderView(p) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
|
|
||||||
|
<div style={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "column",
|
||||||
|
justifyContent: "center",
|
||||||
|
alignItems: "center"
|
||||||
|
}}>
|
||||||
|
<PopUp displayState={popUpToggleAbgeben ? "block" : "none"} hint={"Willst du wirklich abgeben?"}
|
||||||
|
text1={"Abbrechen"} text2={"Abgeben"}
|
||||||
|
function1={() => {
|
||||||
|
setPopUpToggleAbgeben(false)
|
||||||
|
}}
|
||||||
|
function2={() => {
|
||||||
|
fetch(baseURL + "/module/submit?sessionid=" + localStorage.getItem("sessionid") + "&id=" + localStorage.getItem("moduleid"), {
|
||||||
|
method: "PUT"
|
||||||
|
}).then(() => router.push("/semesteroverviewLecturer"))
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
|
||||||
|
<p style={{
|
||||||
|
fontSize: 40,
|
||||||
|
marginBottom: 60
|
||||||
|
}}>{p.semesterName}</p>
|
||||||
<div className={"calender-direction-wrapper"}>
|
<div className={"calender-direction-wrapper"}>
|
||||||
<div>
|
<div>
|
||||||
<BasicDateCalendar startyear={startYearCalenderSideBar} startday={startDayCalenderSideBar}
|
<BasicDateCalendar startyear={startYearCalenderSideBar} startday={startDayCalenderSideBar}
|
||||||
@@ -519,7 +595,8 @@ export default function CalenderView(p) {
|
|||||||
backgroundColor: "white",
|
backgroundColor: "white",
|
||||||
gap: 5,
|
gap: 5,
|
||||||
}}>
|
}}>
|
||||||
<div style={{borderRadius: 10, padding: 10, backgroundColor: "#f1f1f1"}} className={"box-shadow"}>
|
<div style={{borderRadius: 10, padding: 10, backgroundColor: "#f1f1f1"}}
|
||||||
|
className={"box-shadow"}>
|
||||||
<div>
|
<div>
|
||||||
<div className={"wochen-tag-container"}>
|
<div className={"wochen-tag-container"}>
|
||||||
<div
|
<div
|
||||||
@@ -548,7 +625,10 @@ export default function CalenderView(p) {
|
|||||||
|
|
||||||
|
|
||||||
<div className={"spalte"}
|
<div className={"spalte"}
|
||||||
id={"0"} style={{gridTemplateRows: `repeat(96, ${cellHeight}px)`, backgroundColor: grayedOut[0] ? "#aaaaaa" : "#ffffff"}}
|
id={"0"} style={{
|
||||||
|
gridTemplateRows: `repeat(96, ${cellHeight}px)`,
|
||||||
|
backgroundColor: grayedOut[0] ? "#aaaaaa" : "#ffffff"
|
||||||
|
}}
|
||||||
onMouseDown={e => onMouseDown(e)}
|
onMouseDown={e => onMouseDown(e)}
|
||||||
onMouseMove={e => onMouseMove(e)}
|
onMouseMove={e => onMouseMove(e)}
|
||||||
onMouseUp={e => onMouseUp(e)}>
|
onMouseUp={e => onMouseUp(e)}>
|
||||||
@@ -557,24 +637,27 @@ export default function CalenderView(p) {
|
|||||||
width: "100%",
|
width: "100%",
|
||||||
gridRowStart: d.timestart,
|
gridRowStart: d.timestart,
|
||||||
gridRowEnd: d.timeend,
|
gridRowEnd: d.timeend,
|
||||||
backgroundColor: getEntryColor(d.usercreatedbyid, 0, d.semesterid)
|
backgroundColor: getEntryColor(d.usercreatedbyid, 0, d.semesterid, d.moduleid)
|
||||||
}} id={d.id + "e"}>
|
}} id={d.id + "e"}>
|
||||||
<div className={"resize-grab"} id={"grabup"} style={{
|
<div className={"resize-grab"} id={"grabup"} style={{
|
||||||
backgroundColor: getResizeBarColor(d.usercreatedbyid, 0, d.semesterid)
|
backgroundColor: getResizeBarColor(d.usercreatedbyid, 0, d.semesterid, d.moduleid)
|
||||||
}}></div>
|
}}></div>
|
||||||
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
|
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
|
||||||
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
|
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
|
||||||
<p>{d.info}</p>
|
<p>{d.info}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className={"resize-grab"} id={"grabdown"} style={{
|
<div className={"resize-grab"} id={"grabdown"} style={{
|
||||||
backgroundColor: getResizeBarColor(d.usercreatedbyid, 0, d.semesterid)
|
backgroundColor: getResizeBarColor(d.usercreatedbyid, 0, d.semesterid, d.moduleid)
|
||||||
}}></div>
|
}}></div>
|
||||||
</div>))}
|
</div>))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div className={"spalte"}
|
<div className={"spalte"}
|
||||||
id={"1"} style={{gridTemplateRows: `repeat(96, ${cellHeight}px)`, backgroundColor: grayedOut[1] ? "#aaaaaa" : "#ffffff"}}
|
id={"1"} style={{
|
||||||
|
gridTemplateRows: `repeat(96, ${cellHeight}px)`,
|
||||||
|
backgroundColor: grayedOut[1] ? "#aaaaaa" : "#ffffff"
|
||||||
|
}}
|
||||||
onMouseDown={e => onMouseDown(e)}
|
onMouseDown={e => onMouseDown(e)}
|
||||||
onMouseMove={e => onMouseMove(e)}
|
onMouseMove={e => onMouseMove(e)}
|
||||||
onMouseUp={e => onMouseUp(e)}>
|
onMouseUp={e => onMouseUp(e)}>
|
||||||
@@ -583,25 +666,28 @@ export default function CalenderView(p) {
|
|||||||
width: "100%",
|
width: "100%",
|
||||||
gridRowStart: d.timestart,
|
gridRowStart: d.timestart,
|
||||||
gridRowEnd: d.timeend,
|
gridRowEnd: d.timeend,
|
||||||
backgroundColor: getEntryColor(d.usercreatedbyid, 1, d.semesterid)
|
backgroundColor: getEntryColor(d.usercreatedbyid, 1, d.semesterid, d.moduleid)
|
||||||
}} id={d.id + "e"}>
|
}} id={d.id + "e"}>
|
||||||
|
|
||||||
<div className={"resize-grab"} id={"grabup"} style={{
|
<div className={"resize-grab"} id={"grabup"} style={{
|
||||||
backgroundColor: getResizeBarColor(d.usercreatedbyid, 1, d.semesterid)
|
backgroundColor: getResizeBarColor(d.usercreatedbyid, 1, d.semesterid, d.moduleid)
|
||||||
}}></div>
|
}}></div>
|
||||||
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
|
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
|
||||||
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
|
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
|
||||||
<p>{d.info}</p>
|
<p>{d.info}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className={"resize-grab"} id={"grabdown"} style={{
|
<div className={"resize-grab"} id={"grabdown"} style={{
|
||||||
backgroundColor: getResizeBarColor(d.usercreatedbyid, 1, d.semesterid)
|
backgroundColor: getResizeBarColor(d.usercreatedbyid, 1, d.semesterid, d.moduleid)
|
||||||
}}></div>
|
}}></div>
|
||||||
</div>))}
|
</div>))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div className={"spalte"}
|
<div className={"spalte"}
|
||||||
id={"2"} style={{gridTemplateRows: `repeat(96, ${cellHeight}px)`, backgroundColor: grayedOut[2] ? "#aaaaaa" : "#ffffff"}}
|
id={"2"} style={{
|
||||||
|
gridTemplateRows: `repeat(96, ${cellHeight}px)`,
|
||||||
|
backgroundColor: grayedOut[2] ? "#aaaaaa" : "#ffffff"
|
||||||
|
}}
|
||||||
onMouseDown={e => onMouseDown(e)}
|
onMouseDown={e => onMouseDown(e)}
|
||||||
onMouseMove={e => onMouseMove(e)}
|
onMouseMove={e => onMouseMove(e)}
|
||||||
onMouseUp={e => onMouseUp(e)}>
|
onMouseUp={e => onMouseUp(e)}>
|
||||||
@@ -611,25 +697,28 @@ export default function CalenderView(p) {
|
|||||||
width: "100%",
|
width: "100%",
|
||||||
gridRowStart: d.timestart,
|
gridRowStart: d.timestart,
|
||||||
gridRowEnd: d.timeend,
|
gridRowEnd: d.timeend,
|
||||||
backgroundColor: getEntryColor(d.usercreatedbyid, 2, d.semesterid)
|
backgroundColor: getEntryColor(d.usercreatedbyid, 2, d.semesterid, d.moduleid)
|
||||||
}} id={d.id + "e"}>
|
}} id={d.id + "e"}>
|
||||||
|
|
||||||
<div className={"resize-grab"} id={"grabup"} style={{
|
<div className={"resize-grab"} id={"grabup"} style={{
|
||||||
backgroundColor: getResizeBarColor(d.usercreatedbyid, 2, d.semesterid)
|
backgroundColor: getResizeBarColor(d.usercreatedbyid, 2, d.semesterid, d.moduleid)
|
||||||
}}></div>
|
}}></div>
|
||||||
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
|
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
|
||||||
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
|
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
|
||||||
<p>{d.info}</p>
|
<p>{d.info}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className={"resize-grab"} id={"grabdown"} style={{
|
<div className={"resize-grab"} id={"grabdown"} style={{
|
||||||
backgroundColor: getResizeBarColor(d.usercreatedbyid, 2, d.semesterid)
|
backgroundColor: getResizeBarColor(d.usercreatedbyid, 2, d.semesterid, d.moduleid)
|
||||||
}}></div>
|
}}></div>
|
||||||
</div>))}
|
</div>))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div className={"spalte"}
|
<div className={"spalte"}
|
||||||
id={"3"} style={{gridTemplateRows: `repeat(96, ${cellHeight}px)`, backgroundColor: grayedOut[3] ? "#aaaaaa" : "#ffffff"}}
|
id={"3"} style={{
|
||||||
|
gridTemplateRows: `repeat(96, ${cellHeight}px)`,
|
||||||
|
backgroundColor: grayedOut[3] ? "#aaaaaa" : "#ffffff"
|
||||||
|
}}
|
||||||
onMouseDown={e => onMouseDown(e)}
|
onMouseDown={e => onMouseDown(e)}
|
||||||
onMouseMove={e => onMouseMove(e)}
|
onMouseMove={e => onMouseMove(e)}
|
||||||
onMouseUp={e => onMouseUp(e)}>
|
onMouseUp={e => onMouseUp(e)}>
|
||||||
@@ -638,25 +727,28 @@ export default function CalenderView(p) {
|
|||||||
width: "100%",
|
width: "100%",
|
||||||
gridRowStart: d.timestart,
|
gridRowStart: d.timestart,
|
||||||
gridRowEnd: d.timeend,
|
gridRowEnd: d.timeend,
|
||||||
backgroundColor: getEntryColor(d.usercreatedbyid, 3, d.semesterid)
|
backgroundColor: getEntryColor(d.usercreatedbyid, 3, d.semesterid, d.moduleid)
|
||||||
}} id={d.id + "e"}>
|
}} id={d.id + "e"}>
|
||||||
|
|
||||||
<div className={"resize-grab"} id={"grabup"} style={{
|
<div className={"resize-grab"} id={"grabup"} style={{
|
||||||
backgroundColor: getResizeBarColor(d.usercreatedbyid, 3, d.semesterid)
|
backgroundColor: getResizeBarColor(d.usercreatedbyid, 3, d.semesterid, d.moduleid)
|
||||||
}}></div>
|
}}></div>
|
||||||
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
|
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
|
||||||
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
|
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
|
||||||
<p>{d.info}</p>
|
<p>{d.info}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className={"resize-grab"} id={"grabdown"} style={{
|
<div className={"resize-grab"} id={"grabdown"} style={{
|
||||||
backgroundColor: getResizeBarColor(d.usercreatedbyid, 3, d.semesterid)
|
backgroundColor: getResizeBarColor(d.usercreatedbyid, 3, d.semesterid, d.moduleid)
|
||||||
}}></div>
|
}}></div>
|
||||||
</div>))}
|
</div>))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div className={"spalte"}
|
<div className={"spalte"}
|
||||||
id={"4"} style={{gridTemplateRows: `repeat(96, ${cellHeight}px)`, backgroundColor: grayedOut[4] ? "#aaaaaa" : "#ffffff"}}
|
id={"4"} style={{
|
||||||
|
gridTemplateRows: `repeat(96, ${cellHeight}px)`,
|
||||||
|
backgroundColor: grayedOut[4] ? "#aaaaaa" : "#ffffff"
|
||||||
|
}}
|
||||||
onMouseDown={e => onMouseDown(e)}
|
onMouseDown={e => onMouseDown(e)}
|
||||||
onMouseMove={e => onMouseMove(e)}
|
onMouseMove={e => onMouseMove(e)}
|
||||||
onMouseUp={e => onMouseUp(e)}>
|
onMouseUp={e => onMouseUp(e)}>
|
||||||
@@ -666,24 +758,27 @@ export default function CalenderView(p) {
|
|||||||
width: "100%",
|
width: "100%",
|
||||||
gridRowStart: d.timestart,
|
gridRowStart: d.timestart,
|
||||||
gridRowEnd: d.timeend,
|
gridRowEnd: d.timeend,
|
||||||
backgroundColor: getEntryColor(d.usercreatedbyid, 4, d.semesterid)
|
backgroundColor: getEntryColor(d.usercreatedbyid, 4, d.semesterid, d.moduleid)
|
||||||
}} id={d.id + "e"}>
|
}} id={d.id + "e"}>
|
||||||
<div className={"resize-grab"} id={"grabup"} style={{
|
<div className={"resize-grab"} id={"grabup"} style={{
|
||||||
backgroundColor: getResizeBarColor(d.usercreatedbyid, 4, d.semesterid)
|
backgroundColor: getResizeBarColor(d.usercreatedbyid, 4, d.semesterid, d.moduleid)
|
||||||
}}></div>
|
}}></div>
|
||||||
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
|
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
|
||||||
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
|
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
|
||||||
<p>{d.info}</p>
|
<p>{d.info}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className={"resize-grab"} id={"grabdown"} style={{
|
<div className={"resize-grab"} id={"grabdown"} style={{
|
||||||
backgroundColor: getResizeBarColor(d.usercreatedbyid, 4, d.semesterid)
|
backgroundColor: getResizeBarColor(d.usercreatedbyid, 4, d.semesterid, d.moduleid)
|
||||||
}}></div>
|
}}></div>
|
||||||
</div>))}
|
</div>))}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
<div className={"spalte"}
|
<div className={"spalte"}
|
||||||
id={"5"} style={{gridTemplateRows: `repeat(96, ${cellHeight}px)`, backgroundColor: grayedOut[5] ? "#aaaaaa" : "#ffffff"}}
|
id={"5"} style={{
|
||||||
|
gridTemplateRows: `repeat(96, ${cellHeight}px)`,
|
||||||
|
backgroundColor: grayedOut[5] ? "#aaaaaa" : "#ffffff"
|
||||||
|
}}
|
||||||
onMouseDown={e => onMouseDown(e)}
|
onMouseDown={e => onMouseDown(e)}
|
||||||
onMouseMove={e => onMouseMove(e)}
|
onMouseMove={e => onMouseMove(e)}
|
||||||
onMouseUp={e => onMouseUp(e)}>
|
onMouseUp={e => onMouseUp(e)}>
|
||||||
@@ -693,17 +788,17 @@ export default function CalenderView(p) {
|
|||||||
width: "100%",
|
width: "100%",
|
||||||
gridRowStart: d.timestart,
|
gridRowStart: d.timestart,
|
||||||
gridRowEnd: d.timeend,
|
gridRowEnd: d.timeend,
|
||||||
backgroundColor: getEntryColor(d.usercreatedbyid, 5, d.semesterid)
|
backgroundColor: getEntryColor(d.usercreatedbyid, 5, d.semesterid, d.moduleid)
|
||||||
}} id={d.id + "e"}>
|
}} id={d.id + "e"}>
|
||||||
<div className={"resize-grab"} id={"grabup"} style={{
|
<div className={"resize-grab"} id={"grabup"} style={{
|
||||||
backgroundColor: getResizeBarColor(d.usercreatedbyid, 5, d.semesterid)
|
backgroundColor: getResizeBarColor(d.usercreatedbyid, 5, d.semesterid, d.moduleid)
|
||||||
}}></div>
|
}}></div>
|
||||||
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
|
<div style={{maxHeight: "60%"}} className={"no-pointer-events"}>
|
||||||
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
|
<p>{internal_to_time(d.timestart) + " - " + internal_to_time(d.timeend)}</p>
|
||||||
<p>{d.info}</p>
|
<p>{d.info}</p>
|
||||||
</div>
|
</div>
|
||||||
<div className={"resize-grab"} id={"grabdown"} style={{
|
<div className={"resize-grab"} id={"grabdown"} style={{
|
||||||
backgroundColor: getResizeBarColor(d.usercreatedbyid, 5, d.semesterid)
|
backgroundColor: getResizeBarColor(d.usercreatedbyid, 5, d.semesterid, d.moduleid)
|
||||||
}}></div>
|
}}></div>
|
||||||
</div>))}
|
</div>))}
|
||||||
</div>
|
</div>
|
||||||
@@ -784,10 +879,10 @@ export default function CalenderView(p) {
|
|||||||
<div className={"error-bar"}>
|
<div className={"error-bar"}>
|
||||||
{errorState.map((e, index) => (
|
{errorState.map((e, index) => (
|
||||||
<div style={{
|
<div style={{
|
||||||
|
display: e === ErrorType.Okay ? "none" : "flex",
|
||||||
width: "90%",
|
width: "90%",
|
||||||
backgroundColor: e === ErrorType.Okay ? "white" : "#e5a10e",
|
backgroundColor: e === ErrorType.Okay ? "white" : "#e5a10e",
|
||||||
borderRadius: 15,
|
borderRadius: 15,
|
||||||
display: "flex",
|
|
||||||
flexDirection: "column",
|
flexDirection: "column",
|
||||||
justifyContent: "center",
|
justifyContent: "center",
|
||||||
gap: 10,
|
gap: 10,
|
||||||
@@ -811,5 +906,24 @@ export default function CalenderView(p) {
|
|||||||
</div>))}
|
</div>))}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<p style={{
|
||||||
|
display: typeof window !== "undefined" && localStorage.getItem("admin") == 0 ? "block" : "none",
|
||||||
|
marginTop: 10,
|
||||||
|
fontSize: 20
|
||||||
|
}}>{Math.floor(timePlanned)}h {(Math.floor(timePlanned * 3) - Math.floor(Math.floor(timePlanned) * 3)) * 15} min
|
||||||
|
// 20h</p>
|
||||||
|
|
||||||
|
<div style={{
|
||||||
|
display: typeof window !== "undefined" && localStorage.getItem("admin") == 0 ? "block" : "none",
|
||||||
|
position: "absolute",
|
||||||
|
right: 70,
|
||||||
|
bottom: 20,
|
||||||
|
}}>
|
||||||
|
<Button color={timePlanned < 20 ? "#AAAAAA": "#77932b"} onClick={() => {
|
||||||
|
Math.floor(timePlanned) == 20 ? setPopUpToggleAbgeben(true) : {}
|
||||||
|
}} text={"Abgeben"} width={100} height={40}/>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -3,407 +3,364 @@ import {useRouter} from "next/router";
|
|||||||
import {useEffect, useState} from "react";
|
import {useEffect, useState} from "react";
|
||||||
import Background from "@/components/Background";
|
import Background from "@/components/Background";
|
||||||
import {baseURL} from "@/components/Constants";
|
import {baseURL} from "@/components/Constants";
|
||||||
|
import Back from "@/components/Back";
|
||||||
|
|
||||||
|
let modulesDummy = [
|
||||||
|
["Analysis", "Theo Inf 1"],
|
||||||
|
["Lineare Algebra", "Anwendungsprojekt"],
|
||||||
|
["Theo Inf 3", "Software Eng"],
|
||||||
|
["Security", "BWL"],
|
||||||
|
["Software Eng", "Security"],
|
||||||
|
["Studienarbeit", "Bachelor"]
|
||||||
|
]
|
||||||
|
|
||||||
let userModuleMapping = new Map()
|
let tempSemesterNumber = 0
|
||||||
|
let update = false
|
||||||
|
|
||||||
|
let baseMapping = []
|
||||||
|
|
||||||
export default function InputForm(p) {
|
export default function InputForm(p) {
|
||||||
|
|
||||||
let startDateParam = "";
|
const [startDate, setStartDate] = useState("0000-00-00")
|
||||||
let endDateParam = "";
|
const [endDate, setEndDate] = useState("0000-00-00")
|
||||||
let courseNameParam = "";
|
const [courseName, setCourseName] = useState("")
|
||||||
|
const [semesterNumber, setSemesterNumber] = useState(0)
|
||||||
if (p.startDate != null) startDateParam = p.startDate;
|
const [users, setUsers] = useState([])
|
||||||
if (p.endDate != null) endDateParam = p.endDate;
|
const [modulesSelectorValues, setModulesSelectorValues] = useState(["nothing", "nothing"])
|
||||||
if (p.courseName != null) courseNameParam = p.courseName;
|
const [userModulesMapping, setUserModulesMapping] = useState({})
|
||||||
|
const [isChecked, setIsChecked] = useState([])
|
||||||
const router = useRouter();
|
const [isActivated, setIsActivated] = useState([])
|
||||||
|
const router = useRouter()
|
||||||
const [startDate, setStartDate] = useState(startDateParam);
|
|
||||||
const [endDate, setEndDate] = useState(endDateParam);
|
|
||||||
const [courseName, setCourseName] = useState(courseNameParam);
|
|
||||||
const [users, setUsers] = useState([]);
|
|
||||||
const [checkedSelected, setCheckedSelected] = useState(new Array(100).fill(false))
|
|
||||||
const [activatedSelected, setActivatedSelected] = useState(new Array(100).fill(false))
|
|
||||||
const [modulesNames, setModulesNames] = useState(new Array(100).fill("Please Select"))
|
|
||||||
|
|
||||||
async function getAllUsers() {
|
|
||||||
let sessionid = localStorage.getItem("sessionid");
|
|
||||||
let url = baseURL + "/users/all?sessionid=" + sessionid;
|
|
||||||
|
|
||||||
await fetch(url).then(response => response.json()).then(async user => {
|
|
||||||
setUsers(user)
|
|
||||||
let mURL = baseURL + "/module/suid?sessionid=" + localStorage.getItem("sessionid") + "&semesterid=" + localStorage.getItem("currentsid") + "&userid=";
|
|
||||||
for(let i = 0; i < user.length; i++)
|
|
||||||
{
|
|
||||||
mURL += user[i].id;
|
|
||||||
if(i < user.length - 1)
|
|
||||||
{
|
|
||||||
mURL += "a";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fetch(mURL).then(result => result.json()).then(m => {
|
|
||||||
let temp = []
|
|
||||||
|
|
||||||
for(let i = 0; i < user.length; i++)
|
|
||||||
{
|
|
||||||
temp.push(m[i] != null);
|
|
||||||
}
|
|
||||||
|
|
||||||
setCheckedSelected(temp);
|
|
||||||
|
|
||||||
temp = []
|
|
||||||
|
|
||||||
for(let i = 0; i < user.length; i++)
|
|
||||||
{
|
|
||||||
temp.push(m[i] != null && m[i].activated === 1);
|
|
||||||
|
|
||||||
if(m[i] != null) {
|
|
||||||
let tempModuleInfo = new UserModuleInfo();
|
|
||||||
tempModuleInfo.setModuleName(m[i].name);
|
|
||||||
tempModuleInfo.setActivated(m[i].activated);
|
|
||||||
tempModuleInfo.setChecked(true);
|
|
||||||
tempModuleInfo.setUserid(user[i].id)
|
|
||||||
userModuleMapping.set(user[i].id, tempModuleInfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
setActivatedSelected(temp);
|
|
||||||
|
|
||||||
temp = []
|
|
||||||
|
|
||||||
for(let i = 0; i < user.length; i++)
|
|
||||||
{
|
|
||||||
temp.push(m[i] == null ? "Please Select" : m[i].name);
|
|
||||||
}
|
|
||||||
|
|
||||||
setModulesNames(temp);
|
|
||||||
|
|
||||||
});
|
|
||||||
|
|
||||||
for(let i = 0; i < user.length; i++)
|
|
||||||
{
|
|
||||||
if(!userModuleMapping.has(user[i].id)) {
|
|
||||||
let tempModuleInfo = new UserModuleInfo();
|
|
||||||
tempModuleInfo.setModuleName("Please Select");
|
|
||||||
tempModuleInfo.setActivated(0);
|
|
||||||
tempModuleInfo.setChecked(false);
|
|
||||||
tempModuleInfo.setUserid(user[i].id)
|
|
||||||
userModuleMapping.set(user[i].id, tempModuleInfo)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getAllUsers()
|
|
||||||
userModuleMapping.clear();
|
setTimeout(() => {
|
||||||
|
update = false;
|
||||||
|
baseMapping = []
|
||||||
|
|
||||||
|
let base = baseURL + "/semester/id?sessionid=" + localStorage.getItem("sessionid") + "&id=" + localStorage.getItem("currentsid")
|
||||||
|
fetch(base).then(r => r.json()).then(j => {
|
||||||
|
|
||||||
|
tempSemesterNumber = j.number
|
||||||
|
setSemesterNumber(j.number)
|
||||||
|
|
||||||
|
|
||||||
|
setCourseName(j.name)
|
||||||
|
|
||||||
|
let tempStartDate = new Date(parseInt(j.startyear), 0, parseInt(j.startday))
|
||||||
|
let tempEndDate = new Date(parseInt(j.endyear), 0, parseInt(j.endday))
|
||||||
|
|
||||||
|
setStartDate(tempStartDate.getFullYear() + "-" + ((tempStartDate.getMonth() + 1).toString().padStart(2, "0")) + "-" + tempStartDate.getDate().toString().padStart(2, "0"))
|
||||||
|
setEndDate(tempEndDate.getFullYear() + "-" + ((tempEndDate.getMonth() + 1).toString().padStart(2, "0")) + "-" + tempEndDate.getDate().toString().padStart(2, "0"))
|
||||||
|
}).then(() => {
|
||||||
|
readModules()
|
||||||
|
update = true
|
||||||
|
}).catch(() => readModules())
|
||||||
|
}, 100)
|
||||||
|
|
||||||
|
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
|
function readModules() {
|
||||||
|
let usersTemp = []
|
||||||
|
|
||||||
async function onCreateClicked() {
|
let userURL = baseURL + "/users/all?sessionid=" + localStorage.getItem("sessionid")
|
||||||
let startSplit = startDate.split("-");
|
fetch(userURL).then(r => r.json()).then(j => {
|
||||||
let endSplit = endDate.split("-");
|
setUsers(j)
|
||||||
let startYear = parseInt(startSplit[0]);
|
usersTemp = j
|
||||||
let endYear = parseInt(endSplit[0]);
|
let temp = [false, false, false]
|
||||||
|
let temp2 = []
|
||||||
|
for (let i = 0; i < j.length; i++) {
|
||||||
|
temp.push(false)
|
||||||
|
temp2.push(false)
|
||||||
|
}
|
||||||
|
setIsChecked(temp)
|
||||||
|
setIsActivated(temp2)
|
||||||
|
}).then(() => {
|
||||||
|
let modulesURL = baseURL + "/module/bysemesterid?sessionid=" + localStorage.getItem("sessionid") + "&semesterid=" + localStorage.getItem("currentsid");
|
||||||
|
fetch(modulesURL).then(r => r.json()).then(j => {
|
||||||
|
|
||||||
//month - 1 because jan = 0, day like month... but because of next lines 3 to 4 not - 1
|
setUserModulesMapping(j)
|
||||||
let startInternalDate = new Date(startYear, parseInt(startSplit[1]) - 1, parseInt(startSplit[2]))
|
baseMapping = j
|
||||||
let endInternalDate = new Date(endYear, parseInt(endSplit[1]) - 1, parseInt(endSplit[2]))
|
|
||||||
|
|
||||||
let startDayInYear = Math.round((startInternalDate - new Date(startYear, 0, 0)) / (1000 * 60 * 60 * 24));
|
let temp = isChecked.slice()
|
||||||
let endDayInYear = Math.round((endInternalDate - new Date(endYear, 0, 0)) / (1000 * 60 * 60 * 24));
|
let temp2 = isActivated.slice()
|
||||||
|
|
||||||
let id = p.courseName == null ? 0 : localStorage.getItem("currentsid");
|
for (let i = 0; i < usersTemp.length; i++) {
|
||||||
|
let currentUser = usersTemp[i]
|
||||||
|
|
||||||
let json = {
|
let found = false
|
||||||
"id": id,
|
let foundModuleLast = null
|
||||||
|
for (let f = 0; f < j.length; f++) {
|
||||||
|
let currentModule = j[f]
|
||||||
|
|
||||||
|
if (currentModule.userid === currentUser.id) {
|
||||||
|
found = true
|
||||||
|
foundModuleLast = currentModule
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found) {
|
||||||
|
temp[i] = true
|
||||||
|
|
||||||
|
temp2[i] = foundModuleLast.activated === 1
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setIsChecked(temp)
|
||||||
|
setIsActivated(temp2)
|
||||||
|
}).then(() => {
|
||||||
|
setModulesSelectorValues(modulesDummy[tempSemesterNumber])
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCourseNameChange(e) {
|
||||||
|
setCourseName(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onStartDateChange(e) {
|
||||||
|
setStartDate(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onEndDateChange(e) {
|
||||||
|
setEndDate(e.target.value)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onSemesterNumberChange(e) {
|
||||||
|
setSemesterNumber(e.target.value)
|
||||||
|
setModulesSelectorValues(modulesDummy[e.target.value])
|
||||||
|
}
|
||||||
|
|
||||||
|
function isOptionSelected(e, userid) {
|
||||||
|
let found = false;
|
||||||
|
|
||||||
|
for (let i = 0; i < userModulesMapping.length; i++) {
|
||||||
|
let current = userModulesMapping[i]
|
||||||
|
if (current.name === e && current.userid === userid) {
|
||||||
|
found = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return found;
|
||||||
|
}
|
||||||
|
|
||||||
|
function onCheckedChange(e, index) {
|
||||||
|
let temp = isChecked.slice()
|
||||||
|
temp[index] = e.target.checked
|
||||||
|
setIsChecked(temp)
|
||||||
|
|
||||||
|
if (!e.target.checked) {
|
||||||
|
let temp = []
|
||||||
|
let currentUser = users[index]
|
||||||
|
for (let j = 0; j < userModulesMapping.length; j++) {
|
||||||
|
if (userModulesMapping[j].userid !== currentUser.id) {
|
||||||
|
temp.push(userModulesMapping[j])
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
setUserModulesMapping(temp)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onActivatedChange(e, index) {
|
||||||
|
|
||||||
|
let temp = isActivated.slice()
|
||||||
|
temp[index] = e.target.checked
|
||||||
|
setIsActivated(temp)
|
||||||
|
|
||||||
|
let userid = users[index].id
|
||||||
|
|
||||||
|
for (let j = 0; j < userModulesMapping.length; j++) {
|
||||||
|
if (userModulesMapping[j].userid === userid) {
|
||||||
|
userModulesMapping[j].activated = e.target.checked ? 1 : 0
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function onModuleSelectionChange(e, index) {
|
||||||
|
let userid = users[index].id
|
||||||
|
|
||||||
|
let newMapping = []
|
||||||
|
let oldNamesIds = new Map()
|
||||||
|
|
||||||
|
for (let j = 0; j < userModulesMapping.length; j++) {
|
||||||
|
let currentModuleMapping = userModulesMapping[j]
|
||||||
|
if (currentModuleMapping.userid != userid) {
|
||||||
|
newMapping.push(currentModuleMapping)
|
||||||
|
} else {
|
||||||
|
oldNamesIds.set(currentModuleMapping.name, currentModuleMapping.id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let found = false
|
||||||
|
for (let i = 0; i < e.target.options.length; i++) {
|
||||||
|
|
||||||
|
let currentOption = e.target.options[i]
|
||||||
|
if (currentOption.selected) {
|
||||||
|
found = true
|
||||||
|
|
||||||
|
newMapping.push({
|
||||||
|
"id": oldNamesIds.has(currentOption.value) ? oldNamesIds.get(currentOption.value) : -1,
|
||||||
|
"userid": userid,
|
||||||
|
"semesterid": -1,
|
||||||
|
"name": currentOption.value,
|
||||||
|
"activated": isActivated[index] ? 1 : 0
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
let temp = isChecked.slice()
|
||||||
|
temp[index] = found
|
||||||
|
setIsChecked(temp)
|
||||||
|
|
||||||
|
setUserModulesMapping(newMapping)
|
||||||
|
}
|
||||||
|
|
||||||
|
function onButtonAbort() {
|
||||||
|
router.back()
|
||||||
|
}
|
||||||
|
|
||||||
|
function onButtonSave() {
|
||||||
|
let tempDateStart = new Date(parseInt(startDate.split("-")[0]), parseInt(startDate.split("-")[1]) - 1, parseInt(startDate.split("-")[2]))
|
||||||
|
let tempDateEnd = new Date(parseInt(endDate.split("-")[0]), parseInt(endDate.split("-")[1]) - 1, parseInt(endDate.split("-")[2]))
|
||||||
|
|
||||||
|
let startDayInYear = Math.round((tempDateStart - new Date(tempDateStart.getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24))
|
||||||
|
let endDayInYear = Math.round((tempDateEnd - new Date(tempDateEnd.getFullYear(), 0, 0)) / (1000 * 60 * 60 * 24))
|
||||||
|
|
||||||
|
|
||||||
|
let semesterJson = {
|
||||||
|
"id": update ? localStorage.getItem("currentsid") : 0,
|
||||||
"startday": startDayInYear,
|
"startday": startDayInYear,
|
||||||
"endday": endDayInYear,
|
"endday": endDayInYear,
|
||||||
"name": courseName,
|
"name": courseName,
|
||||||
"startyear": startYear,
|
"startyear": tempDateStart.getFullYear(),
|
||||||
"endyear": endYear
|
"endyear": tempDateEnd.getFullYear(),
|
||||||
|
"number": semesterNumber
|
||||||
}
|
}
|
||||||
|
|
||||||
let url = baseURL + "/semester?sessionid=" + localStorage.getItem("sessionid");
|
fetch(baseURL + "/semester?sessionid=" + localStorage.getItem("sessionid"), {
|
||||||
let method = p.courseName == null ? "POST" : "PUT";
|
method: update ? "PUT" : "POST",
|
||||||
|
|
||||||
|
|
||||||
let semesterid = localStorage.getItem("currentsid");
|
|
||||||
let tempsid = 0;
|
|
||||||
await fetch(url, {
|
|
||||||
method: method,
|
|
||||||
headers: {"Content-Type": "application/json"},
|
headers: {"Content-Type": "application/json"},
|
||||||
body: JSON.stringify(json)
|
body: JSON.stringify(semesterJson)
|
||||||
}).then(response => response.json()).then(semester => {
|
}).then(r => r.json()).then(async sem => {
|
||||||
tempsid = semester.id
|
let semesterID = sem.id
|
||||||
});
|
|
||||||
|
|
||||||
|
for (let i = 0; i < baseMapping.length; i++) {
|
||||||
if (method === "POST") {
|
let found = false
|
||||||
semesterid = tempsid;
|
for (let j = 0; j < userModulesMapping.length; j++) {
|
||||||
|
if (baseMapping[i].name === userModulesMapping[j].name) {
|
||||||
|
found = true
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (let [key, value] of userModuleMapping) {
|
if (!found) {
|
||||||
|
fetch(baseURL + "/module?sessionid=" + localStorage.getItem("sessionid") + "&id=" + baseMapping[i].id, {
|
||||||
let json1 = {
|
|
||||||
"id": 0,
|
|
||||||
"userid": value.getUserid(),
|
|
||||||
"semesterid": semesterid,
|
|
||||||
"name": value.getModuleName(),
|
|
||||||
"activated": value.getActivated()
|
|
||||||
}
|
|
||||||
if (value.getChecked()) {
|
|
||||||
let updateURL = baseURL + "/module?sessionid=" + localStorage.getItem("sessionid");
|
|
||||||
await fetch(updateURL, {
|
|
||||||
method: method,
|
|
||||||
headers: {"Content-Type": "application/json"},
|
|
||||||
body: JSON.stringify(json1)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
let deleteURL = baseURL + "/module?sessionid=" + localStorage.getItem("sessionid") +
|
|
||||||
"&semesterid=" + semesterid +
|
|
||||||
"&userid=" + value.getUserid();
|
|
||||||
await fetch(deleteURL, {
|
|
||||||
method: "DELETE"
|
method: "DELETE"
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
router.back();
|
for (let i = 0; i < userModulesMapping.length; i++) {
|
||||||
}
|
|
||||||
|
|
||||||
class UserModuleInfo {
|
userModulesMapping[i].semesterid = semesterID
|
||||||
constructor() {
|
setTimeout(() => {
|
||||||
this.moduleName = "";
|
fetch(baseURL + "/module?sessionid=" + localStorage.getItem("sessionid"), {
|
||||||
this.userid = 0;
|
method: userModulesMapping[i].id === -1 ? "POST" : "PUT",
|
||||||
this.activated = 0
|
headers: {"Content-Type": "application/json"},
|
||||||
this.checked = false
|
body: JSON.stringify(userModulesMapping[i])
|
||||||
}
|
})
|
||||||
|
}, i * 200)
|
||||||
getModuleName() {
|
|
||||||
return this.moduleName
|
|
||||||
}
|
|
||||||
|
|
||||||
getUserid() {
|
|
||||||
return this.userid
|
|
||||||
}
|
|
||||||
|
|
||||||
getActivated() {
|
|
||||||
return this.activated
|
|
||||||
}
|
|
||||||
|
|
||||||
getChecked() {
|
|
||||||
return this.checked
|
|
||||||
}
|
|
||||||
|
|
||||||
setModuleName(name) {
|
|
||||||
this.moduleName = name
|
|
||||||
}
|
|
||||||
|
|
||||||
setUserid(id) {
|
|
||||||
this.userid = id
|
|
||||||
}
|
|
||||||
|
|
||||||
setActivated(a) {
|
|
||||||
this.activated = a
|
|
||||||
}
|
|
||||||
|
|
||||||
setChecked(b) {
|
|
||||||
this.checked = b
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function onModuleClicked(user, module, index) {
|
|
||||||
|
|
||||||
if (userModuleMapping.has(user.id)) {
|
|
||||||
let temp = userModuleMapping.get(user.id)
|
|
||||||
temp.setModuleName(module)
|
|
||||||
temp.setUserid(user.id)
|
|
||||||
}
|
|
||||||
|
|
||||||
let temp = [];
|
|
||||||
|
|
||||||
for(let i = 0; i < modulesNames.length; i++)
|
|
||||||
{
|
|
||||||
temp.push(modulesNames[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
temp[index] = module;
|
|
||||||
|
|
||||||
setModulesNames(temp);
|
|
||||||
}
|
|
||||||
|
|
||||||
function onSelectedCheckBox(user, state, index) {
|
|
||||||
if (userModuleMapping.has(user.id)) {
|
|
||||||
userModuleMapping.get(user.id).setChecked(state.target.checked);
|
|
||||||
} else {
|
|
||||||
let temp = new UserModuleInfo()
|
|
||||||
temp.setChecked(state.target.checked)
|
|
||||||
temp.setUserid(user.id)
|
|
||||||
userModuleMapping.set(user.id, temp)
|
|
||||||
}
|
|
||||||
let temp = []
|
|
||||||
|
|
||||||
for(let i = 0; i < checkedSelected.length; i++)
|
|
||||||
{
|
|
||||||
temp.push(checkedSelected[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
temp[index] = state.target.checked;
|
|
||||||
|
|
||||||
setCheckedSelected(temp);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
})
|
||||||
|
|
||||||
function onActivatedCheckBox(user, state, index) {
|
router.back()
|
||||||
if (userModuleMapping.has(user.id)) {
|
|
||||||
let t = state.target.checked ? 1 : 0;
|
|
||||||
userModuleMapping.get(user.id).setActivated(t);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let temp = []
|
|
||||||
|
|
||||||
for(let i = 0; i < checkedSelected.length; i++)
|
|
||||||
{
|
|
||||||
temp.push(activatedSelected[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
temp[index] = state.target.checked;
|
|
||||||
|
|
||||||
setActivatedSelected(temp);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<Background/>
|
<Background/>
|
||||||
<div className="inputForm box-shadow">
|
<div className={"box-shadow input-form round-border"}>
|
||||||
<p style={{
|
|
||||||
fontSize: "18px",
|
<p>Kursname</p>
|
||||||
color: "#777777",
|
<input type={"text"} className={"box-shadow round-border"} style={{padding: 8, width: "100%", backgroundColor: (courseName == "") ? "#E44747" : "white"}}
|
||||||
fontWeight: 500,
|
onChange={e => onCourseNameChange(e)} value={courseName}/>
|
||||||
width: 150
|
|
||||||
}}>Kursname</p>
|
<div style={{display: "flex", justifyContent: "flex-start", gap: 40}}>
|
||||||
<input className="courseNameInput box-shadow" value={courseName}
|
<p>Theorie Anfang</p>
|
||||||
onChange={(e) => setCourseName(e.target.value)}/>
|
<p>Theorie Ende</p>
|
||||||
<div className="semesterRangeInput">
|
|
||||||
<div className="semesterDateLables">
|
|
||||||
<p className="semesterDateLable" style={{
|
|
||||||
fontSize: " 18px",
|
|
||||||
color: "#777777",
|
|
||||||
fontWeight: 500,
|
|
||||||
width: 150
|
|
||||||
}}>Theorie Anfang</p>
|
|
||||||
<p className="semesterDateLable" style={{
|
|
||||||
fontSize: " 18px",
|
|
||||||
color: "#777777",
|
|
||||||
fontWeight: 500,
|
|
||||||
width: 150
|
|
||||||
}}>Theorie Ende</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div className={"MeinTest"}>
|
<div style={{display: "flex", justifyContent: "flex-start", gap: 20}}>
|
||||||
<div className="semesterDateInputPair">
|
<input type={"date"} className={"box-shadow round-border"} style={{padding: 8, backgroundColor: (startDate == "" || startDate >= endDate) ? "#E44747" : "white"
|
||||||
<input type="date" id="start" className={"box-shadow selector"} value={startDate}
|
|
||||||
style={{
|
|
||||||
padding: 5,
|
|
||||||
backgroundColor: (startDate == "" || startDate >= endDate) ? "#E44747" : "white"
|
|
||||||
}}
|
}}
|
||||||
onChange={(e) => setStartDate(e.target.value)}/>
|
onChange={e => onStartDateChange(e)} value={startDate}/>
|
||||||
<p className="inputFieldSeperator">-</p>
|
<input type={"date"} className={"box-shadow round-border"} style={{padding: 8, backgroundColor: (endDate == "" || startDate >= endDate) ? "#E44747" : "white"
|
||||||
<input type="date" id="start" className={"box-shadow selector"} value={endDate}
|
|
||||||
style={{
|
|
||||||
padding: 5,
|
|
||||||
backgroundColor: (endDate == "" || startDate >= endDate) ? "#E44747" : "white"
|
|
||||||
}}
|
}}
|
||||||
onChange={(e) => setEndDate(e.target.value)}/>
|
onChange={e => onEndDateChange(e)} value={endDate}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
|
||||||
</div>
|
<p>Semester Wählen</p>
|
||||||
<div className="round-border dozentSelector">
|
<select className={"round-border box-shadow"} style={{padding: 5, width: "100%"}} value={semesterNumber}
|
||||||
|
onChange={e => onSemesterNumberChange(e)}>
|
||||||
|
<option value={0}>1. Semester</option>
|
||||||
|
<option value={1}>2. Semester</option>
|
||||||
|
<option value={2}>3. Semester</option>
|
||||||
|
<option value={3}>4. Semester</option>
|
||||||
|
<option value={4}>5. Semester</option>
|
||||||
|
<option value={5}>6. Semester</option>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<div className={"table-wrapper"}>
|
||||||
<table>
|
<table>
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
<th style={{
|
<th>Wählen</th>
|
||||||
fontSize: " 18px",
|
<th>Freischalten</th>
|
||||||
color: "#777777",
|
<th>Dozent</th>
|
||||||
fontWeight: 500,
|
<th>Modul</th>
|
||||||
}}>Wählen
|
|
||||||
</th>
|
|
||||||
<th style={{
|
|
||||||
fontSize: " 18px",
|
|
||||||
color: "#777777",
|
|
||||||
fontWeight: 500,
|
|
||||||
}}>Freischalten
|
|
||||||
</th>
|
|
||||||
<th style={{
|
|
||||||
fontSize: " 18px",
|
|
||||||
color: "#777777",
|
|
||||||
fontWeight: 500,
|
|
||||||
textAlign: "center"
|
|
||||||
}}>Dozent
|
|
||||||
</th>
|
|
||||||
<th style={{
|
|
||||||
fontSize: " 18px",
|
|
||||||
color: "#777777",
|
|
||||||
fontWeight: 500,
|
|
||||||
textAlign: "center",
|
|
||||||
}}>Modul
|
|
||||||
</th>
|
|
||||||
</tr>
|
</tr>
|
||||||
{users.map((user, i) => (
|
{
|
||||||
|
users.map((user, index) => (
|
||||||
<tr>
|
<tr>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<div style={{
|
<input type={"checkbox"} checked={isChecked[index]}
|
||||||
display: "flex",
|
onChange={e => onCheckedChange(e, index)}/>
|
||||||
flexDirection: "row",
|
|
||||||
justifyContent: "center",
|
|
||||||
}}><input type="checkbox" onChange={(e) => {
|
|
||||||
onSelectedCheckBox(user, e, i)
|
|
||||||
}} checked={checkedSelected[i]}/></div>
|
|
||||||
</td>
|
</td>
|
||||||
|
|
||||||
<td>
|
<td>
|
||||||
<div style={{
|
<input type={"checkbox"} checked={isActivated[index]}
|
||||||
display: "flex",
|
onChange={e => onActivatedChange(e, index)}/>
|
||||||
flexDirection: "row",
|
|
||||||
justifyContent: "center",
|
|
||||||
}}><input type="checkbox" onChange={(e) => {
|
|
||||||
onActivatedCheckBox(user, e, i);
|
|
||||||
}} checked={activatedSelected[i]}/></div>
|
|
||||||
</td>
|
</td>
|
||||||
<td style={{textAlign: "center"}}>{user.firstName + " " + user.lastName}</td>
|
<td>
|
||||||
<select id={"userSelect"} name={"userSelect"} className={"box-shadow selector"}
|
{user.firstName + " " + user.lastName}
|
||||||
multiple={false} style={{
|
</td>
|
||||||
maxHeight: 80,
|
<td>
|
||||||
marginTop: 10,
|
<select multiple={true} className={"box-shadow round-border"}
|
||||||
padding: "5px 2px"
|
style={{padding: 5}}
|
||||||
}} onChange={(e) => {
|
onChange={e => onModuleSelectionChange(e, index)}>
|
||||||
onModuleClicked(user, e.target.value, i)
|
{modulesSelectorValues.map(msv => (
|
||||||
}} value={modulesNames[i]}>
|
<option value={msv}
|
||||||
<option value={"Please Select"}>Please Select</option>
|
selected={isOptionSelected(msv, user.id)}>{msv}</option>
|
||||||
<option value={"Programmieren"}>Programmieren</option>
|
|
||||||
<option value={"BWL"}>BWL</option>
|
|
||||||
<option value={"Lineare Algebra"}>Lineare Algebra</option>
|
|
||||||
<option value={"Analysis"}>Analysis</option>
|
|
||||||
<option value={"AnwendungsProjekt"}>AnwendungsProjekt</option>
|
|
||||||
</select>
|
|
||||||
</tr>
|
|
||||||
))}
|
))}
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
))
|
||||||
|
}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
<div id="buttons">
|
|
||||||
<Button color="rgba(54,54,54,0.64)" width="100px" height="30px" text="Abbrechen" onClick={() => {
|
<div style={{
|
||||||
router.back()
|
display: "flex",
|
||||||
}}/>
|
justifyContent: "flex-end",
|
||||||
<Button color="#77932b" width="100px" height="30px" text="Speichern" onClick={() => { (startDate == "" || endDate == ""|| startDate >= endDate) ? () => {} : onCreateClicked()}
|
alignItems: "center",
|
||||||
}/>
|
width: "100%",
|
||||||
|
gap: 10
|
||||||
|
}}>
|
||||||
|
<Button text={"Abbrechen"} onClick={onButtonAbort}/>
|
||||||
|
<Button text={"Speichern"} color={"#77932b"} onClick={() => { (startDate == "" || endDate == ""|| startDate >= endDate || courseName == "") ? () => {} : onButtonSave()}}/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
|||||||
@@ -9,7 +9,8 @@ export default function PopUp(p) {
|
|||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div style={{
|
<div style={{
|
||||||
display: p.displayState
|
display: p.displayState,
|
||||||
|
zIndex: 1000
|
||||||
}}>
|
}}>
|
||||||
|
|
||||||
<div className={"modal-container"}>
|
<div className={"modal-container"}>
|
||||||
|
|||||||
@@ -1,8 +1,4 @@
|
|||||||
import StatusBar from "@/components/StatusBar";
|
|
||||||
import React, {useEffect} from "react";
|
import React, {useEffect} from "react";
|
||||||
import Button from "@/components/Button";
|
|
||||||
import {deleteItem, editItem} from "@/components/Icons";
|
|
||||||
|
|
||||||
export default function SemesterTile(p)
|
export default function SemesterTile(p)
|
||||||
{
|
{
|
||||||
let editable = true;
|
let editable = true;
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
import React from "react"
|
import React, {useState} from "react"
|
||||||
|
import {baseURL} from "@/components/Constants";
|
||||||
|
import {console} from "next/dist/compiled/@edge-runtime/primitives/console";
|
||||||
|
|
||||||
export default function StatusBar(p)
|
export default function StatusBar(p)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,21 +0,0 @@
|
|||||||
import Button from "@/components/Button";
|
|
||||||
import { baseURL } from "@/components/Constants";
|
|
||||||
import {useRouter} from "next/router";
|
|
||||||
|
|
||||||
export default function SubmitButton() {
|
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div
|
|
||||||
style={{
|
|
||||||
position: "absolute",
|
|
||||||
right: 70,
|
|
||||||
bottom: 20,
|
|
||||||
borderBottomRightRadius: 10,
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Button onClick={() => router.push("/submit")} text={"Abgeben"} color={"#77932b"} width={100} height={40} />
|
|
||||||
</div>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
@@ -1,56 +0,0 @@
|
|||||||
import {baseURL} from "@/components/Constants";
|
|
||||||
import Button from "@/components/Button";
|
|
||||||
|
|
||||||
export default function SubmitWarning(p){
|
|
||||||
|
|
||||||
async function submit() {
|
|
||||||
let url = baseURL + "/module?sessionid=" + localStorage.getItem("sessionid");
|
|
||||||
|
|
||||||
let json1 = {
|
|
||||||
"id": 0,
|
|
||||||
"userid": localStorage.getItem("userid"),
|
|
||||||
"semesterid": localStorage.getItem("currentsid"),
|
|
||||||
"name": localStorage.getItem("currentmodulename"),
|
|
||||||
"activated": 0
|
|
||||||
}
|
|
||||||
|
|
||||||
await fetch(url, {
|
|
||||||
method: "PUT",
|
|
||||||
headers: {"Content-Type": "application/json"},
|
|
||||||
body: JSON.stringify(json1)
|
|
||||||
})
|
|
||||||
|
|
||||||
p.onClick();
|
|
||||||
p.onClick();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
|
||||||
<div className="box-shadow" style={{
|
|
||||||
position: "absolute",
|
|
||||||
top: 300,
|
|
||||||
left: 0,
|
|
||||||
right: 0,
|
|
||||||
borderRadius: 5,
|
|
||||||
textAlign: "center",
|
|
||||||
fontSize: 20,
|
|
||||||
margin: "auto",
|
|
||||||
width: 600
|
|
||||||
|
|
||||||
}}>
|
|
||||||
<p style={{paddingTop: 20, paddingBottom: 5}}>Möchten Sie wirklich abgeben?</p>
|
|
||||||
<p>Danach können Sie keine Änderungen mehr vornehmen!</p>
|
|
||||||
<div style={{
|
|
||||||
display: "flex",
|
|
||||||
flexDirection: "row",
|
|
||||||
justifyContent: "center",
|
|
||||||
paddingTop: 40,
|
|
||||||
paddingBottom: 20
|
|
||||||
}}>
|
|
||||||
<Button onClick={() => submit()} text={"Bestätigen"} color={"#77932b"} width={100} height={40} />
|
|
||||||
<div style={{width: 20}}></div>
|
|
||||||
<Button onClick={() => p.onClick()} text={"Abbrechen"} color={"red"} width={100} height={40} />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -5,21 +5,26 @@ import Back from "@/components/Back";
|
|||||||
import BasicDateCalendar from "@/components/CalendarSideBar";
|
import BasicDateCalendar from "@/components/CalendarSideBar";
|
||||||
import {useRouter} from "next/router";
|
import {useRouter} from "next/router";
|
||||||
import HelpButton from "@/components/HelpButton";
|
import HelpButton from "@/components/HelpButton";
|
||||||
import SubmitButton from "@/components/SubmitButton";
|
|
||||||
|
|
||||||
|
|
||||||
export default function planning(p)
|
export default function planning(p)
|
||||||
{
|
{
|
||||||
let router = useRouter()
|
let router = useRouter()
|
||||||
|
|
||||||
|
let semesterName;
|
||||||
|
|
||||||
|
if (typeof window !== 'undefined'){
|
||||||
|
semesterName = localStorage.getItem("semestername") + " " + (localStorage.getItem("admin") == 1 ? "" : localStorage.getItem("currentmodulename"))
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"normal-centered"}>
|
<div className={"normal-centered"}>
|
||||||
<Logout/>
|
<Logout/>
|
||||||
<Back onClick={() => router.back()}/>
|
<Back onClick={() => router.back()}/>
|
||||||
<HelpButton/>
|
<HelpButton/>
|
||||||
<Background/>
|
<Background/>
|
||||||
<CalenderView/>
|
<CalenderView semesterName={semesterName}/>
|
||||||
<SubmitButton />
|
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
@@ -12,12 +12,76 @@ import StatusBar from "@/components/StatusBar";
|
|||||||
import {deleteItem, editItem} from "@/components/Icons";
|
import {deleteItem, editItem} from "@/components/Icons";
|
||||||
|
|
||||||
export default function SemesterOverview(p) {
|
export default function SemesterOverview(p) {
|
||||||
async function getSemesters() {
|
|
||||||
|
const [progresses, setProgresses] = useState([])
|
||||||
|
|
||||||
|
async function getSemesters(set) {
|
||||||
let urlTest = baseURL + "/semester/all?sessionid=" + localStorage.getItem("sessionid");
|
let urlTest = baseURL + "/semester/all?sessionid=" + localStorage.getItem("sessionid");
|
||||||
|
|
||||||
|
let allSemesters
|
||||||
|
let allModules
|
||||||
|
let allEntries
|
||||||
|
|
||||||
await fetch(urlTest).then(response => response.json()).then(s => {
|
await fetch(urlTest).then(response => response.json()).then(s => {
|
||||||
|
allSemesters = s
|
||||||
|
if (set) {
|
||||||
setEntries(s)
|
setEntries(s)
|
||||||
|
}
|
||||||
|
}).then(() => {
|
||||||
|
if(!set)
|
||||||
|
{
|
||||||
|
fetch(baseURL + "/module/all?sessionid=" + localStorage.getItem("sessionid")).then(r => r.json()).then(mod => {
|
||||||
|
allModules = mod
|
||||||
|
}).then(() => {
|
||||||
|
fetch(baseURL + "/entries/all?sessionid=" + localStorage.getItem("sessionid")).then(r => r.json()).then(en => {
|
||||||
|
allEntries = en
|
||||||
|
}).then(() => {
|
||||||
|
let modulesCountInSemester = []
|
||||||
|
for (let i = 0; i < allSemesters.length; i++) {
|
||||||
|
let count = 0
|
||||||
|
for (let j = 0; j < allModules.length; j++) {
|
||||||
|
if (allSemesters[i].id === allModules[j].semesterid) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
modulesCountInSemester.push(count)
|
||||||
|
}
|
||||||
|
|
||||||
|
let temp = []
|
||||||
|
for (let s = 0; s < allSemesters.length; s++) {
|
||||||
|
let count = 0;
|
||||||
|
|
||||||
|
for (let i = 0; i < allModules.length; i++) {
|
||||||
|
if (allModules[i].semesterid === allSemesters[s].id) {
|
||||||
|
let sum = 0
|
||||||
|
let ent = allEntries.filter(e => e.moduleid === allModules[i].id)
|
||||||
|
for (let j = 0; j < ent.length; j++) {
|
||||||
|
sum += ent[j].timeend - ent[j].timestart
|
||||||
|
}
|
||||||
|
|
||||||
|
sum /= 3
|
||||||
|
|
||||||
|
if (sum >= 20 && allModules[i].activated === 0) {
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count === 0) {
|
||||||
|
temp.push(0)
|
||||||
|
} else if (count >= 1 && count !== modulesCountInSemester[s]) {
|
||||||
|
temp.push(50)
|
||||||
|
} else {
|
||||||
|
temp.push(100)
|
||||||
|
}
|
||||||
|
|
||||||
|
setProgresses(temp)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -26,6 +90,7 @@ export default function SemesterOverview(p) {
|
|||||||
if (m.target === m.currentTarget) {
|
if (m.target === m.currentTarget) {
|
||||||
localStorage.setItem("currentsid", e.id)
|
localStorage.setItem("currentsid", e.id)
|
||||||
router.push("/planning")
|
router.push("/planning")
|
||||||
|
localStorage.setItem("semestername", e.name + " Sem. " + (e.number + 1))
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -56,7 +121,7 @@ export default function SemesterOverview(p) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
togglePopup();
|
togglePopup();
|
||||||
getSemesters();
|
getSemesters(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function funcButtonEdit(e, m) {
|
async function funcButtonEdit(e, m) {
|
||||||
@@ -80,13 +145,18 @@ export default function SemesterOverview(p) {
|
|||||||
endDate: endDate.toISOString().slice(0, 10)
|
endDate: endDate.toISOString().slice(0, 10)
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
getSemesters();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
getSemesters();
|
|
||||||
|
getSemesters(true);
|
||||||
|
|
||||||
}, [])
|
}, [])
|
||||||
|
useEffect(() => {
|
||||||
|
setTimeout(() => {
|
||||||
|
getSemesters(false)
|
||||||
|
}, 1000)
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
const [entries, setEntries] = useState([])
|
const [entries, setEntries] = useState([])
|
||||||
@@ -100,9 +170,10 @@ export default function SemesterOverview(p) {
|
|||||||
<HelpButton/>
|
<HelpButton/>
|
||||||
<Background/>
|
<Background/>
|
||||||
{
|
{
|
||||||
entries.map(e => (
|
entries.map((e, index) => (
|
||||||
<div className={"semester-tile box-shadow"}>
|
<div className={"semester-tile box-shadow"} onClick={(f) => onClickSemester(e, f)}>
|
||||||
<SemesterTile text={e.name} onClick={(f) => onClickSemester(e, f)} onButtonDeleteClick={() => {
|
<SemesterTile text={e.name + " Sem. " + (e.number + 1)} onClick={(f) => onClickSemester(e, f)}
|
||||||
|
onButtonDeleteClick={() => {
|
||||||
localStorage.setItem("currentsid", e.id)
|
localStorage.setItem("currentsid", e.id)
|
||||||
setModalHint(e.name + " Löschen?");
|
setModalHint(e.name + " Löschen?");
|
||||||
togglePopup();
|
togglePopup();
|
||||||
@@ -110,7 +181,7 @@ export default function SemesterOverview(p) {
|
|||||||
localStorage.setItem("currentsid", e.id)
|
localStorage.setItem("currentsid", e.id)
|
||||||
funcButtonEdit(e, m);
|
funcButtonEdit(e, m);
|
||||||
}}/>
|
}}/>
|
||||||
<StatusBar progress={0}/>
|
<StatusBar progress={progresses[index]}/>
|
||||||
<div style={
|
<div style={
|
||||||
{
|
{
|
||||||
display: "flex",
|
display: "flex",
|
||||||
|
|||||||
@@ -8,6 +8,9 @@ import HelpButton from "@/components/HelpButton";
|
|||||||
import StatusBar from "@/components/StatusBar";
|
import StatusBar from "@/components/StatusBar";
|
||||||
|
|
||||||
export default function SemesteroverviewLecturer(p) {
|
export default function SemesteroverviewLecturer(p) {
|
||||||
|
|
||||||
|
const [timeStamps, setTimeStamps] = useState([])
|
||||||
|
|
||||||
function getModules() {
|
function getModules() {
|
||||||
let urlTest = baseURL + "/module/id?sessionid=" + localStorage.getItem("sessionid");
|
let urlTest = baseURL + "/module/id?sessionid=" + localStorage.getItem("sessionid");
|
||||||
|
|
||||||
@@ -26,19 +29,43 @@ export default function SemesteroverviewLecturer(p) {
|
|||||||
let semesterURL = baseURL + "/semester/id/all?ids=" + args + "&sessionid=" + localStorage.getItem("sessionid");
|
let semesterURL = baseURL + "/semester/id/all?ids=" + args + "&sessionid=" + localStorage.getItem("sessionid");
|
||||||
fetch(semesterURL).then(r => r.json()).then(sem => {
|
fetch(semesterURL).then(r => r.json()).then(sem => {
|
||||||
sem.map(e => {
|
sem.map(e => {
|
||||||
temp.push(e.name)
|
temp.push(e.name + " Sem. " + (e.number + 1))
|
||||||
|
})
|
||||||
|
}).then(() => setSemesterNames(temp)).then(() => {
|
||||||
|
let entriesURL = baseURL + "/entries/all?sessionid=" + localStorage.getItem("sessionid")
|
||||||
|
fetch(entriesURL).then(r => r.json()).then(en => {
|
||||||
|
let tempTimeStamps = []
|
||||||
|
for(let j = 0; j < m.length; j++)
|
||||||
|
{
|
||||||
|
let sum = 0
|
||||||
|
let currentModule = m[j]
|
||||||
|
for (let i = 0; i < en.length; i++)
|
||||||
|
{
|
||||||
|
if(currentModule.id === en[i].moduleid)
|
||||||
|
{
|
||||||
|
sum += en[i].timeend - en[i].timestart
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sum /= 3
|
||||||
|
tempTimeStamps.push(sum)
|
||||||
|
}
|
||||||
|
|
||||||
|
setTimeStamps(tempTimeStamps)
|
||||||
|
|
||||||
|
})
|
||||||
})
|
})
|
||||||
}).then(() => setSemesterNames(temp))
|
|
||||||
})
|
})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function onClickSemester(e, m) {
|
function onClickSemester(e, m, name) {
|
||||||
if (e.activated == 1) {
|
if (e.activated == 1) {
|
||||||
if (m.target === m.currentTarget) {
|
if (m.target === m.currentTarget) {
|
||||||
localStorage.setItem("currentsid", e.semesterid)
|
localStorage.setItem("currentsid", e.semesterid)
|
||||||
localStorage.setItem("currentmodulename", e.name)
|
localStorage.setItem("currentmodulename", e.name)
|
||||||
localStorage.setItem("moduleid", e.id)
|
localStorage.setItem("moduleid", e.id)
|
||||||
|
localStorage.setItem("semestername", name)
|
||||||
router.push("/planning")
|
router.push("/planning")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -46,13 +73,32 @@ export default function SemesteroverviewLecturer(p) {
|
|||||||
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
setTimeout(() => {
|
||||||
getModules();
|
getModules();
|
||||||
|
}, 1000)
|
||||||
}, [])
|
}, [])
|
||||||
|
|
||||||
const [entries, setEntries] = useState([]);
|
const [entries, setEntries] = useState([]);
|
||||||
const [semesterNames, setSemesterNames] = useState([]);
|
const [semesterNames, setSemesterNames] = useState([]);
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|
||||||
|
function getProgressForTime(time, activated)
|
||||||
|
{
|
||||||
|
console.log(activated)
|
||||||
|
|
||||||
|
if(time === 0)
|
||||||
|
{
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
else if( 20 >= time > 0 && activated === 1)
|
||||||
|
{
|
||||||
|
return 50
|
||||||
|
}
|
||||||
|
else if(time >= 20 && activated === 0)
|
||||||
|
{
|
||||||
|
return 100
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className={"semester-overview"}>
|
<div className={"semester-overview"}>
|
||||||
@@ -62,12 +108,12 @@ export default function SemesteroverviewLecturer(p) {
|
|||||||
{entries.map((e, index) => (
|
{entries.map((e, index) => (
|
||||||
<div className={"semester-tile box-shadow"} style={{
|
<div className={"semester-tile box-shadow"} style={{
|
||||||
backgroundColor: e.activated == 1 ? "#ffffff" : "#aaaaaa"
|
backgroundColor: e.activated == 1 ? "#ffffff" : "#aaaaaa"
|
||||||
}}>
|
}} onClick={(f) => onClickSemester(e, f, semesterNames[index])}>
|
||||||
<SemesterTile
|
<SemesterTile
|
||||||
editable={false} text={semesterNames[index]} text2={e.name}
|
editable={false} text={semesterNames[index]} text2={e.name}
|
||||||
onClick={(f) => onClickSemester(e, f)}
|
onClick={(f) => onClickSemester(e, f, semesterNames[index])}
|
||||||
/>
|
/>
|
||||||
<StatusBar progress={0}/>
|
<StatusBar progress={getProgressForTime(timeStamps[index], e.activated)} module={e}/>
|
||||||
</div>
|
</div>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,19 +0,0 @@
|
|||||||
import Logout from "@/components/Logout";
|
|
||||||
import SubmitWarning from "@/components/SubmitWarning";
|
|
||||||
import Back from "@/components/Back";
|
|
||||||
import {useRouter} from "next/router";
|
|
||||||
import Background from "@/components/Background";
|
|
||||||
|
|
||||||
export default function Submit(){
|
|
||||||
|
|
||||||
const router = useRouter();
|
|
||||||
|
|
||||||
return(
|
|
||||||
<div>
|
|
||||||
<Background />
|
|
||||||
<Logout />
|
|
||||||
<SubmitWarning onClick={() => router.back()}/>
|
|
||||||
<Back onClick={() => router.back()}/>
|
|
||||||
</div>
|
|
||||||
)
|
|
||||||
}
|
|
||||||
@@ -73,6 +73,48 @@ body {
|
|||||||
box-shadow: 0 0 10px rgba(0, 0, 0,1);
|
box-shadow: 0 0 10px rgba(0, 0, 0,1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
Input Form
|
||||||
|
*/
|
||||||
|
|
||||||
|
.input-form
|
||||||
|
{
|
||||||
|
width: 600px;
|
||||||
|
background-color: white;
|
||||||
|
padding: 30px;
|
||||||
|
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
justify-content: space-around;
|
||||||
|
align-items: flex-start;
|
||||||
|
gap: 20px;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
table
|
||||||
|
{
|
||||||
|
width: 550px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.table-wrapper
|
||||||
|
{
|
||||||
|
max-height: 40%;
|
||||||
|
overflow-y: scroll;
|
||||||
|
}
|
||||||
|
|
||||||
|
td
|
||||||
|
{
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
.input-form p, .input-form th
|
||||||
|
{
|
||||||
|
font-size: 18px;
|
||||||
|
font-weight: bold;
|
||||||
|
color: #5e5e5e;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Button
|
Button
|
||||||
*/
|
*/
|
||||||
@@ -117,6 +159,7 @@ Step Progress Bar
|
|||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
max-width: 400px;
|
max-width: 400px;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.steps {
|
.steps {
|
||||||
@@ -127,6 +170,7 @@ Step Progress Bar
|
|||||||
gap: 20px;
|
gap: 20px;
|
||||||
width: 100%;
|
width: 100%;
|
||||||
position: relative;
|
position: relative;
|
||||||
|
pointer-events: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.step {
|
.step {
|
||||||
@@ -138,6 +182,8 @@ Step Progress Bar
|
|||||||
justify-content: center;
|
justify-content: center;
|
||||||
color: white;
|
color: white;
|
||||||
font-weight: bold;
|
font-weight: bold;
|
||||||
|
pointer-events: none;
|
||||||
|
z-index: 101;
|
||||||
}
|
}
|
||||||
|
|
||||||
.steps .not-started {
|
.steps .not-started {
|
||||||
@@ -168,7 +214,7 @@ Step Progress Bar
|
|||||||
position: absolute;
|
position: absolute;
|
||||||
height: 8px;
|
height: 8px;
|
||||||
background-color: #5d606e;
|
background-color: #5d606e;
|
||||||
z-index: -1;
|
z-index: 100;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -391,99 +437,6 @@ Calender View
|
|||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
inputForm
|
|
||||||
*/
|
|
||||||
|
|
||||||
input {
|
|
||||||
border-width: 2px;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.courseNameInput {
|
|
||||||
width: 300px;
|
|
||||||
padding: 5px;
|
|
||||||
border: none;
|
|
||||||
background-color: white;
|
|
||||||
border-radius: 5px;
|
|
||||||
font-family: Arial, serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
.selector
|
|
||||||
{
|
|
||||||
border-width: 0;
|
|
||||||
border-radius: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.semesterDateInput {
|
|
||||||
width: 150px;
|
|
||||||
padding: 5px;
|
|
||||||
border: none;
|
|
||||||
background-color: white;
|
|
||||||
border-radius: 5px;
|
|
||||||
font-family: Arial, serif;
|
|
||||||
}
|
|
||||||
|
|
||||||
.semesterDateLables, .semesterDateInputPair {
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
justify-content: left;
|
|
||||||
padding: 0;
|
|
||||||
border: none;
|
|
||||||
background-color: white;
|
|
||||||
border-radius: 5px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.inputFieldSeperator {
|
|
||||||
width: 40px;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.semesterDateLable {
|
|
||||||
margin-right: 32px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.semesterRangeInput {
|
|
||||||
margin-top: 50px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.inputForm {
|
|
||||||
width: 600px;
|
|
||||||
height: 600px;
|
|
||||||
padding: 20px;
|
|
||||||
/*border: solid;*/
|
|
||||||
border-radius: 10px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
background-color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
#buttons {
|
|
||||||
align-self: flex-end;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
align-items: flex-end;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.dozentSelector {
|
|
||||||
height: 350px;
|
|
||||||
/*border: solid;*/
|
|
||||||
margin-top: 20px;
|
|
||||||
width: 500px;
|
|
||||||
padding: 10px;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
}
|
|
||||||
|
|
||||||
th {
|
|
||||||
text-align: left;
|
|
||||||
padding: 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
td {
|
|
||||||
padding: 0 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Login
|
Login
|
||||||
*/
|
*/
|
||||||
@@ -574,9 +527,6 @@ SemesterTile
|
|||||||
font-size: 23px;
|
font-size: 23px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.semester-tile .step-container {
|
|
||||||
pointer-events: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.Error
|
.Error
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,33 +0,0 @@
|
|||||||
HELP.md
|
|
||||||
target/
|
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
|
||||||
!**/src/main/**/target/
|
|
||||||
!**/src/test/**/target/
|
|
||||||
|
|
||||||
### STS ###
|
|
||||||
.apt_generated
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
.sts4-cache
|
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
|
||||||
.idea
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
|
|
||||||
### NetBeans ###
|
|
||||||
/nbproject/private/
|
|
||||||
/nbbuild/
|
|
||||||
/dist/
|
|
||||||
/nbdist/
|
|
||||||
/.nb-gradle/
|
|
||||||
build/
|
|
||||||
!**/src/main/**/build/
|
|
||||||
!**/src/test/**/build/
|
|
||||||
|
|
||||||
### VS Code ###
|
|
||||||
.vscode/
|
|
||||||
+3
@@ -3,3 +3,6 @@
|
|||||||
/workspace.xml
|
/workspace.xml
|
||||||
# Editor-based HTTP Client requests
|
# Editor-based HTTP Client requests
|
||||||
/httpRequests/
|
/httpRequests/
|
||||||
|
# Datasource local storage ignored files
|
||||||
|
/dataSources/
|
||||||
|
/dataSources.local.xml
|
||||||
Generated
+18
@@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="backend" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
</component>
|
||||||
|
<component name="JavacSettings">
|
||||||
|
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
|
||||||
|
<module name="backend" options="-parameters" />
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+6
@@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+20
@@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
||||||
Generated
+12
@@ -0,0 +1,12 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_20" default="true" project-jdk-name="20" project-jdk-type="JavaSDK" />
|
||||||
|
</project>
|
||||||
Generated
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="VcsDirectoryMappings">
|
<component name="VcsDirectoryMappings">
|
||||||
<mapping directory="" vcs="Git" />
|
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
||||||
Binary file not shown.
+767464
File diff suppressed because it is too large.
Load diff
@@ -10,15 +10,12 @@ import java.sql.*;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class DataBaseHandler
|
public class DataBaseHandler {
|
||||||
{
|
|
||||||
//singleton instance of database handler
|
//singleton instance of database handler
|
||||||
private static DataBaseHandler instance = null;
|
private static DataBaseHandler instance = null;
|
||||||
|
|
||||||
public static DataBaseHandler getInstance()
|
public static DataBaseHandler getInstance() {
|
||||||
{
|
if (instance == null) {
|
||||||
if (instance == null)
|
|
||||||
{
|
|
||||||
instance = new DataBaseHandler();
|
instance = new DataBaseHandler();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -31,30 +28,27 @@ public class DataBaseHandler
|
|||||||
private Statement st;
|
private Statement st;
|
||||||
private boolean encrypted = false;
|
private boolean encrypted = false;
|
||||||
|
|
||||||
public DataBaseHandler()
|
public DataBaseHandler() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
//connect to the local database
|
//connect to the local database
|
||||||
connection = DriverManager.getConnection("jdbc:h2:./database", "adm", "73bgjfdsfJ!934");
|
connection = DriverManager.getConnection("jdbc:h2:./database", "adm", "73bgjfdsfJ!934");
|
||||||
st = connection.createStatement();
|
st = connection.createStatement();
|
||||||
} catch (SQLException e)
|
} catch (SQLException e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
ENTRIES
|
* ENTRIES
|
||||||
*/
|
*/
|
||||||
public void addEntry(Entry entry)
|
public void addEntry(Entry entry)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
st.executeUpdate("insert into entries (daynumber, yearnumber, semesterid, usercreatedbyid, timestart, timeend, info) values (" +
|
st.executeUpdate("insert into entries (daynumber, yearnumber, semesterid, usercreatedbyid, timestart, timeend, moduleid, info) values (" +
|
||||||
entry.getDaynumber() + ", " + entry.getYearnumber() + ", " + entry.getSemesterid() + ", " +
|
entry.getDaynumber() + ", " + entry.getYearnumber() + ", " + entry.getSemesterid() + ", " +
|
||||||
entry.getUsercreatedbyid() + ", " + entry.getTimestart() + ", " + entry.getTimeend() + ", '" + entry.getInfo() + "')"
|
entry.getUsercreatedbyid() + ", " + entry.getTimestart() + ", " + entry.getTimeend() + ", " + entry.getModuleid() + " ,'" + entry.getInfo() + "')"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
catch(Exception e)
|
catch(Exception e)
|
||||||
@@ -63,10 +57,8 @@ public class DataBaseHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entry[][] getEntries(int semesterid, int daynumber, int yearnumber)
|
public Entry[][] getEntries(int semesterid, int daynumber, int yearnumber) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from entries where " +
|
ResultSet rs = st.executeQuery("select * from entries where " +
|
||||||
"semesterid=" + semesterid +
|
"semesterid=" + semesterid +
|
||||||
" and yearnumber=" + yearnumber +
|
" and yearnumber=" + yearnumber +
|
||||||
@@ -74,20 +66,16 @@ public class DataBaseHandler
|
|||||||
|
|
||||||
List<Entry> entryList = new ArrayList<>();
|
List<Entry> entryList = new ArrayList<>();
|
||||||
Entry current = null;
|
Entry current = null;
|
||||||
while((current = resultSetToEntry(rs)) != null)
|
while ((current = resultSetToEntry(rs)) != null) {
|
||||||
{
|
|
||||||
entryList.add(current);
|
entryList.add(current);
|
||||||
}
|
}
|
||||||
|
|
||||||
Entry[][] entries = new Entry[6][20];
|
Entry[][] entries = new Entry[6][20];
|
||||||
for(int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++) {
|
||||||
{
|
|
||||||
int f = 0;
|
int f = 0;
|
||||||
|
|
||||||
for(int j = 0; j < entryList.size(); j++)
|
for (int j = 0; j < entryList.size(); j++) {
|
||||||
{
|
if (entryList.get(j).getDaynumber() == i + daynumber) {
|
||||||
if(entryList.get(j).getDaynumber() == i + daynumber)
|
|
||||||
{
|
|
||||||
entries[i][f] = entryList.get(j);
|
entries[i][f] = entryList.get(j);
|
||||||
f++;
|
f++;
|
||||||
}
|
}
|
||||||
@@ -95,16 +83,13 @@ public class DataBaseHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
return entries;
|
return entries;
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Entry[][] getAllEntrys(int semesterid, int daynumber, int yearnumber, int userid)
|
public Entry[][] getAllEntrys(int semesterid, int daynumber, int yearnumber, int userid) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
ResultSet rs = st.executeQuery("select * from entries where " +
|
ResultSet rs = st.executeQuery("select * from entries where " +
|
||||||
"semesterid<>" + semesterid +
|
"semesterid<>" + semesterid +
|
||||||
@@ -113,37 +98,31 @@ public class DataBaseHandler
|
|||||||
" and daynumber between " + daynumber + " and " + daynumber + 6);
|
" and daynumber between " + daynumber + " and " + daynumber + 6);
|
||||||
List<Entry> entryList = new ArrayList<>();
|
List<Entry> entryList = new ArrayList<>();
|
||||||
Entry current = null;
|
Entry current = null;
|
||||||
while((current = resultSetToEntry(rs)) != null)
|
while ((current = resultSetToEntry(rs)) != null) {
|
||||||
{
|
|
||||||
entryList.add(current);
|
entryList.add(current);
|
||||||
}
|
}
|
||||||
Entry[][] entries = new Entry[6][20];
|
Entry[][] entries = new Entry[6][20];
|
||||||
for(int i = 0; i < 6; i++)
|
for (int i = 0; i < 6; i++) {
|
||||||
{
|
|
||||||
int f = 0;
|
int f = 0;
|
||||||
|
|
||||||
for(int j = 0; j < entryList.size(); j++)
|
for (int j = 0; j < entryList.size(); j++) {
|
||||||
{
|
if (entryList.get(j).getDaynumber() == i + daynumber) {
|
||||||
if(entryList.get(j).getDaynumber() == i + daynumber)
|
|
||||||
{
|
|
||||||
entries[i][f] = entryList.get(j);
|
entries[i][f] = entryList.get(j);
|
||||||
f++;
|
f++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return entries;
|
return entries;
|
||||||
}catch(Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Entry[] getAllEntries(int semesterid, int userid)
|
|
||||||
|
public Entry[] getAllEntries()
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
ResultSet rs = st.executeQuery("select * from entries where " +
|
ResultSet rs = st.executeQuery("select * from entries");
|
||||||
"semesterid=" + semesterid +
|
|
||||||
" and usercreatedbyid=" + userid);
|
|
||||||
List<Entry> entriestate = new ArrayList<>();
|
List<Entry> entriestate = new ArrayList<>();
|
||||||
Entry current = null;
|
Entry current = null;
|
||||||
while((current = resultSetToEntry(rs)) != null)
|
while((current = resultSetToEntry(rs)) != null)
|
||||||
@@ -152,30 +131,43 @@ public class DataBaseHandler
|
|||||||
}
|
}
|
||||||
return entriestate.toArray(new Entry[0]);
|
return entriestate.toArray(new Entry[0]);
|
||||||
}catch (Exception e){
|
}catch (Exception e){
|
||||||
|
System.out.println(e.getMessage());
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteEntry(int id)
|
public Entry[] getAllEntriesModule(int moduleid)
|
||||||
{
|
{
|
||||||
try
|
try {
|
||||||
|
ResultSet rs = st.executeQuery("select * from entries where moduleid=" + moduleid);
|
||||||
|
List<Entry> result = new ArrayList<>();
|
||||||
|
Entry current = null;
|
||||||
|
while((current = resultSetToEntry(rs)) != null)
|
||||||
{
|
{
|
||||||
|
result.add(current);
|
||||||
|
}
|
||||||
|
|
||||||
|
return result.toArray(new Entry[0]);
|
||||||
|
}
|
||||||
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
return new Entry[]{};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteEntry(int id) {
|
||||||
|
try {
|
||||||
st.executeUpdate("delete from entries where id=" + id);
|
st.executeUpdate("delete from entries where id=" + id);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateEntry(Entry entry)
|
public void updateEntry(Entry entry) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
st.executeUpdate("update entries set timeend=" + entry.getTimeend() + ", timestart=" + entry.getTimestart() + " where id=" + entry.getId());
|
st.executeUpdate("update entries set timeend=" + entry.getTimeend() + ", timestart=" + entry.getTimestart() + " where id=" + entry.getId());
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -193,6 +185,7 @@ public class DataBaseHandler
|
|||||||
rs.getInt("timestart"),
|
rs.getInt("timestart"),
|
||||||
rs.getInt("timeend"),
|
rs.getInt("timeend"),
|
||||||
rs.getInt("semesterid"),
|
rs.getInt("semesterid"),
|
||||||
|
rs.getInt("moduleid"),
|
||||||
rs.getString("info")
|
rs.getString("info")
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
@@ -204,105 +197,81 @@ public class DataBaseHandler
|
|||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
SEMESTER
|
* SEMESTER
|
||||||
*/
|
*/
|
||||||
//get a semester object by its name
|
//get a semester object by its name
|
||||||
public Semester getSemester(String name)
|
public Semester getSemester(String name) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from SEMESTER where name = '" + name + "'");
|
ResultSet rs = st.executeQuery("select * from SEMESTER where name = '" + name + "'");
|
||||||
return resultSetToSemester(rs);
|
return resultSetToSemester(rs);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Semester getSemester(int id)
|
public Semester getSemester(int id) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from semester where id=" + id);
|
ResultSet rs = st.executeQuery("select * from semester where id=" + id);
|
||||||
return resultSetToSemester(rs);
|
return resultSetToSemester(rs);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//write a new semester to the database returns if process was successful
|
//write a new semester to the database returns if process was successful
|
||||||
public Semester addSemester(Semester s)
|
public Semester addSemester(Semester s) {
|
||||||
{
|
try {
|
||||||
try
|
st.executeUpdate("insert into SEMESTER (startday, endday, name, startyear, endyear, number) values (" + s.getStartday() + ", " + s.getEndday() + ", '" + s.getName() + "', " + s.getStartyear() + ", " + s.getEndyear() + ", " + s.getNumber() + ")");
|
||||||
{
|
|
||||||
st.executeUpdate("insert into SEMESTER (startday, endday, name, startyear, endyear) values (" + s.getStartday() + ", " + s.getEndday() + ", '" + s.getName() + "', " + s.getStartyear() + ", " + s.getEndyear() + ")");
|
|
||||||
return getSemester(s.getName());
|
return getSemester(s.getName());
|
||||||
|
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Semester[] getAllSemesters()
|
public Semester[] getAllSemesters() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from semester");
|
ResultSet rs = st.executeQuery("select * from semester");
|
||||||
List<Semester> semestersList = new ArrayList<>();
|
List<Semester> semestersList = new ArrayList<>();
|
||||||
Semester s = null;
|
Semester s = null;
|
||||||
while((s = resultSetToSemester(rs)) != null)
|
while ((s = resultSetToSemester(rs)) != null) {
|
||||||
{
|
|
||||||
semestersList.add(s);
|
semestersList.add(s);
|
||||||
}
|
}
|
||||||
|
|
||||||
return semestersList.toArray(new Semester[0]);
|
return semestersList.toArray(new Semester[0]);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Semester updateSemester(Semester semester)
|
public Semester updateSemester(Semester semester) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
st.executeUpdate("update semester set startday=" + semester.getStartday() + ", " +
|
st.executeUpdate("update semester set startday=" + semester.getStartday() + ", " +
|
||||||
"endday=" + semester.getEndday() + ", " +
|
"endday=" + semester.getEndday() + ", " +
|
||||||
"name='" + semester.getName() + "', " +
|
"name='" + semester.getName() + "', " +
|
||||||
"startyear=" + semester.getStartyear() + ", " +
|
"startyear=" + semester.getStartyear() + ", " +
|
||||||
|
"number=" + semester.getNumber() + ", " +
|
||||||
"endyear=" + semester.getEndyear() + " where id=" + semester.getId());
|
"endyear=" + semester.getEndyear() + " where id=" + semester.getId());
|
||||||
|
|
||||||
return getSemester(semester.getId());
|
return getSemester(semester.getId());
|
||||||
} catch (SQLException e)
|
} catch (SQLException e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteSemester(int id)
|
public void deleteSemester(int id) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
st.executeUpdate("DELETE FROM modules WHERE semesterid=" + id);
|
st.executeUpdate("DELETE FROM modules WHERE semesterid=" + id);
|
||||||
|
|
||||||
st.executeUpdate("delete from semester where id=" + id);
|
st.executeUpdate("delete from semester where id=" + id);
|
||||||
}
|
st.executeUpdate("delete from entries where semesterid=" + id);
|
||||||
catch(Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Semester resultSetToSemester(ResultSet rs)
|
public Semester resultSetToSemester(ResultSet rs) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
rs.next();
|
rs.next();
|
||||||
return new Semester(
|
return new Semester(
|
||||||
rs.getInt("id"),
|
rs.getInt("id"),
|
||||||
@@ -310,17 +279,16 @@ public class DataBaseHandler
|
|||||||
rs.getInt("endday"),
|
rs.getInt("endday"),
|
||||||
rs.getString("name"),
|
rs.getString("name"),
|
||||||
rs.getInt("startyear"),
|
rs.getInt("startyear"),
|
||||||
rs.getInt("endyear")
|
rs.getInt("endyear"),
|
||||||
|
rs.getInt("number")
|
||||||
);
|
);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
MODULE
|
* MODULE
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//get a module object by its id
|
//get a module object by its id
|
||||||
@@ -328,22 +296,17 @@ public class DataBaseHandler
|
|||||||
try {
|
try {
|
||||||
ResultSet rs = st.executeQuery("SELECT * FROM modules WHERE id=" + id);
|
ResultSet rs = st.executeQuery("SELECT * FROM modules WHERE id=" + id);
|
||||||
return resultSetToModule(rs);
|
return resultSetToModule(rs);
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Module getModule(int userid, int semesterid)
|
public Module getModule(int userid, int semesterid) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from modules where userid=" + userid + " and semesterid=" + semesterid);
|
ResultSet rs = st.executeQuery("select * from modules where userid=" + userid + " and semesterid=" + semesterid);
|
||||||
|
|
||||||
return resultSetToModule(rs);
|
return resultSetToModule(rs);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -354,96 +317,77 @@ public class DataBaseHandler
|
|||||||
ResultSet rs = st.executeQuery("SELECT * FROM modules WHERE userid = " + userid);
|
ResultSet rs = st.executeQuery("SELECT * FROM modules WHERE userid = " + userid);
|
||||||
List<Module> moduleList = new ArrayList<>();
|
List<Module> moduleList = new ArrayList<>();
|
||||||
Module m = null;
|
Module m = null;
|
||||||
while((m = resultSetToModule(rs)) != null)
|
while ((m = resultSetToModule(rs)) != null) {
|
||||||
{
|
|
||||||
moduleList.add(m);
|
moduleList.add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
return moduleList.toArray(new Module[0]);
|
return moduleList.toArray(new Module[0]);
|
||||||
|
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex){
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Module addModule(Module m)
|
public Module addModule(Module m) {
|
||||||
{
|
|
||||||
try {
|
try {
|
||||||
st.executeUpdate("insert into modules (userid, semesterid, name, activated) " +
|
st.executeUpdate("insert into modules (userid, semesterid, name, activated) " +
|
||||||
"Values (" + m.getUserid() + ", " + m.getsemesterid() + ", '" + m.getName() + "', " + m.getActivated() + ")");
|
"Values (" + m.getUserid() + ", " + m.getsemesterid() + ", '" + m.getName() + "', " + m.getActivated() + ")");
|
||||||
return getModule(m.getUserid(), m.getsemesterid());
|
return getModule(m.getUserid(), m.getsemesterid());
|
||||||
|
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Module[] getAllModules() {
|
public Module[] getAllModules() {
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("SELECT * FROM modules");
|
ResultSet rs = st.executeQuery("SELECT * FROM modules");
|
||||||
List<Module> moduleList = new ArrayList<>();
|
List<Module> moduleList = new ArrayList<>();
|
||||||
Module m = null;
|
Module m = null;
|
||||||
while((m = resultSetToModule(rs)) != null)
|
while ((m = resultSetToModule(rs)) != null) {
|
||||||
{
|
|
||||||
moduleList.add(m);
|
moduleList.add(m);
|
||||||
}
|
}
|
||||||
|
|
||||||
return moduleList.toArray(new Module[0]);
|
return moduleList.toArray(new Module[0]);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Module getModuleBySemesterUserID(int userid, int semesterid)
|
public Module updateModule(Module m) {
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from modules where userid=" + userid + " and semesterid=" + semesterid);
|
|
||||||
return resultSetToModule(rs);
|
|
||||||
}
|
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return new Module(-1, 0, 0, "", 0);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public Module updateModule(Module m)
|
|
||||||
{
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Module module = getModule(m.getUserid(), m.getsemesterid());
|
|
||||||
if(module == null)
|
|
||||||
{
|
|
||||||
addModule(m);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
st.executeUpdate("update modules set activated=" + m.getActivated() + ", semesterid=" + m.getsemesterid() + ", name='" + m.getName() + "' where id=" + module.getid());
|
|
||||||
}
|
|
||||||
|
|
||||||
Module test = getModule(m.getUserid(), m.getsemesterid());
|
|
||||||
System.out.println(test.getActivated());
|
st.executeUpdate("update modules set activated=" + m.getActivated() + ", semesterid=" + m.getsemesterid() + ", name='" + m.getName() + "' where id=" + m.getid());
|
||||||
return test;
|
|
||||||
}
|
|
||||||
catch (SQLException ex) {
|
return getModule(m.getid());
|
||||||
|
} catch (SQLException ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean deleteModule(int semesterid, int userid)
|
public void submitModule(int id)
|
||||||
{
|
{
|
||||||
try {
|
try
|
||||||
st.executeUpdate("delete from modules where semesterid=" + semesterid + " and userid=" + userid);
|
{
|
||||||
return true;
|
st.executeUpdate("update modules set activated=0 where id=" + id);
|
||||||
}
|
}
|
||||||
catch(Exception ex) {
|
catch(Exception e)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deleteModule(int id) {
|
||||||
|
try {
|
||||||
|
st.executeUpdate("delete from modules where id=" + id);
|
||||||
|
st.executeUpdate("delete from entries where moduleid=" + id);
|
||||||
|
return true;
|
||||||
|
} catch (Exception ex) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -457,89 +401,72 @@ public class DataBaseHandler
|
|||||||
rs.getInt("semesterid"),
|
rs.getInt("semesterid"),
|
||||||
rs.getString("name"),
|
rs.getString("name"),
|
||||||
rs.getInt("activated"));
|
rs.getInt("activated"));
|
||||||
}
|
} catch (Exception ex) {
|
||||||
catch (Exception ex) {
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
USER
|
* USER
|
||||||
*/
|
*/
|
||||||
|
|
||||||
//Alle User, die nicht admin sind
|
//Alle User, die nicht admin sind
|
||||||
public User[] getAllUsers()
|
public User[] getAllUsers() {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from users where permission=0");
|
ResultSet rs = st.executeQuery("select * from users where permission=0");
|
||||||
|
|
||||||
User u = null;
|
User u = null;
|
||||||
|
|
||||||
List<User> output = new ArrayList<>();
|
List<User> output = new ArrayList<>();
|
||||||
|
|
||||||
while((u = resultSetToUser(rs)) != null)
|
while ((u = resultSetToUser(rs)) != null) {
|
||||||
{
|
|
||||||
u.clearOutPassword();
|
u.clearOutPassword();
|
||||||
output.add(u);
|
output.add(u);
|
||||||
}
|
}
|
||||||
|
|
||||||
return output.toArray(new User[0]);
|
return output.toArray(new User[0]);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//einen User
|
//einen User
|
||||||
public User getUser(String mail, String password)
|
public User getUser(String mail, String password) {
|
||||||
{
|
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from users where mail = '" + mail + "' and password = '" + password + "'");
|
ResultSet rs = st.executeQuery("select * from users where mail = '" + mail + "' and password = '" + password + "'");
|
||||||
return resultSetToUser(rs);
|
return resultSetToUser(rs);
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getUser(int id)
|
public User getUser(int id) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from users where id=" + id);
|
ResultSet rs = st.executeQuery("select * from users where id=" + id);
|
||||||
return resultSetToUser(rs);
|
return resultSetToUser(rs);
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public User getUser(String mail)
|
public User getUser(String mail) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("select * from users where mail='" + mail + "'");
|
ResultSet rs = st.executeQuery("select * from users where mail='" + mail + "'");
|
||||||
User u = resultSetToUser(rs);
|
User u = resultSetToUser(rs);
|
||||||
if (u != null) u.clearOutPassword();
|
if (u != null) u.clearOutPassword();
|
||||||
|
|
||||||
return u;
|
return u;
|
||||||
} catch (SQLException e)
|
} catch (SQLException e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public User resultSetToUser(ResultSet rs)
|
public User resultSetToUser(ResultSet rs) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
rs.next();
|
rs.next();
|
||||||
return new User(
|
return new User(
|
||||||
rs.getInt("id"),
|
rs.getInt("id"),
|
||||||
@@ -549,27 +476,21 @@ public class DataBaseHandler
|
|||||||
rs.getString("password"),
|
rs.getString("password"),
|
||||||
rs.getInt("permission")
|
rs.getInt("permission")
|
||||||
);
|
);
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//add a new user object to the database returns if process was successful
|
//add a new user object to the database returns if process was successful
|
||||||
public User addUser(User user)
|
public User addUser(User user) {
|
||||||
{
|
|
||||||
//check if mail and passwort (key user information) is given
|
//check if mail and passwort (key user information) is given
|
||||||
if (user.getMail() == null || user.getPassword() == null)
|
if (user.getMail() == null || user.getPassword() == null) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
try
|
try {
|
||||||
{
|
|
||||||
String password = user.getPassword();
|
String password = user.getPassword();
|
||||||
if(encrypted)
|
if (encrypted) {
|
||||||
{
|
|
||||||
RSA rsa = RSA.getInstance();
|
RSA rsa = RSA.getInstance();
|
||||||
byte[] psw = rsa.loadByteArray(password);
|
byte[] psw = rsa.loadByteArray(password);
|
||||||
try {
|
try {
|
||||||
@@ -580,20 +501,16 @@ public class DataBaseHandler
|
|||||||
}
|
}
|
||||||
st.executeUpdate("insert into users (firstname, lastname, mail, password, permission) values (" + "'" + user.getFirstName() + "', '" + user.getLastName() + "', '" + user.getMail() + "', '" + password + "', " + 0 + ")");
|
st.executeUpdate("insert into users (firstname, lastname, mail, password, permission) values (" + "'" + user.getFirstName() + "', '" + user.getLastName() + "', '" + user.getMail() + "', '" + password + "', " + 0 + ")");
|
||||||
return getUser(user.getMail(), user.getPassword());
|
return getUser(user.getMail(), user.getPassword());
|
||||||
} catch (Exception e)
|
} catch (Exception e) {
|
||||||
{
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public User updateUser(User user, int id, boolean elevationRequestByAdmin)
|
public User updateUser(User user, int id, boolean elevationRequestByAdmin) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
String password = user.getPassword();
|
String password = user.getPassword();
|
||||||
if(encrypted)
|
if (encrypted) {
|
||||||
{
|
|
||||||
RSA rsa = RSA.getInstance();
|
RSA rsa = RSA.getInstance();
|
||||||
byte[] psw = rsa.loadByteArray(password);
|
byte[] psw = rsa.loadByteArray(password);
|
||||||
try {
|
try {
|
||||||
@@ -603,17 +520,14 @@ public class DataBaseHandler
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(!elevationRequestByAdmin)
|
if (!elevationRequestByAdmin) {
|
||||||
{
|
|
||||||
st.executeUpdate("update users set " +
|
st.executeUpdate("update users set " +
|
||||||
"firstname='" + user.getFirstName() + "', " +
|
"firstname='" + user.getFirstName() + "', " +
|
||||||
"lastname='" + user.getLastName() + "', " +
|
"lastname='" + user.getLastName() + "', " +
|
||||||
"mail='" + user.getMail() + "', " +
|
"mail='" + user.getMail() + "', " +
|
||||||
"password='" + password + "' " +
|
"password='" + password + "' " +
|
||||||
"where id=" + id);
|
"where id=" + id);
|
||||||
}
|
} else {
|
||||||
else
|
|
||||||
{
|
|
||||||
st.executeUpdate("update users set " +
|
st.executeUpdate("update users set " +
|
||||||
"firstname='" + user.getFirstName() + "', " +
|
"firstname='" + user.getFirstName() + "', " +
|
||||||
"lastname='" + user.getLastName() + "', " +
|
"lastname='" + user.getLastName() + "', " +
|
||||||
@@ -624,17 +538,14 @@ public class DataBaseHandler
|
|||||||
}
|
}
|
||||||
|
|
||||||
return getUser(id);
|
return getUser(id);
|
||||||
} catch (SQLException e)
|
} catch (SQLException e) {
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean deleteUser(String mail)
|
public boolean deleteUser(String mail) {
|
||||||
{
|
try {
|
||||||
try
|
|
||||||
{
|
|
||||||
ResultSet rs = st.executeQuery("SELECT id FROM user WHERE mail='" + mail + "'");
|
ResultSet rs = st.executeQuery("SELECT id FROM user WHERE mail='" + mail + "'");
|
||||||
rs.next();
|
rs.next();
|
||||||
int id = rs.getInt("id");
|
int id = rs.getInt("id");
|
||||||
@@ -642,9 +553,7 @@ public class DataBaseHandler
|
|||||||
|
|
||||||
st.executeUpdate("delete from users where mail='" + mail + "'");
|
st.executeUpdate("delete from users where mail='" + mail + "'");
|
||||||
return true;
|
return true;
|
||||||
}
|
} catch (Exception e) {
|
||||||
catch(Exception e)
|
|
||||||
{
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,9 +10,10 @@ public class Entry
|
|||||||
private int timestart;
|
private int timestart;
|
||||||
private int timeend;
|
private int timeend;
|
||||||
private int semesterid;
|
private int semesterid;
|
||||||
|
private int moduleid;
|
||||||
private String info;
|
private String info;
|
||||||
|
|
||||||
public Entry(int id, int daynumber, int yearnumber, int usercreatedbyid, int timestart, int timeend, int semesterid, String info)
|
public Entry(int id, int daynumber, int yearnumber, int usercreatedbyid, int timestart, int timeend, int semesterid, int moduleid, String info)
|
||||||
{
|
{
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.daynumber = daynumber;
|
this.daynumber = daynumber;
|
||||||
@@ -21,6 +22,7 @@ public class Entry
|
|||||||
this.timestart = timestart;
|
this.timestart = timestart;
|
||||||
this.timeend = timeend;
|
this.timeend = timeend;
|
||||||
this.semesterid = semesterid;
|
this.semesterid = semesterid;
|
||||||
|
this.moduleid = moduleid;
|
||||||
this.info = info;
|
this.info = info;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -59,6 +61,8 @@ public class Entry
|
|||||||
return semesterid;
|
return semesterid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getModuleid() {return moduleid;}
|
||||||
|
|
||||||
public String getInfo()
|
public String getInfo()
|
||||||
{
|
{
|
||||||
return info;
|
return info;
|
||||||
|
|||||||
@@ -9,14 +9,16 @@ public class Semester
|
|||||||
private String name;
|
private String name;
|
||||||
private int startyear;
|
private int startyear;
|
||||||
private int endyear;
|
private int endyear;
|
||||||
|
private int number;
|
||||||
|
|
||||||
public Semester(int id, int startday, int endday, String name, int startyear, int endyear) {
|
public Semester(int id, int startday, int endday, String name, int startyear, int endyear, int number) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.startday = startday;
|
this.startday = startday;
|
||||||
this.endday = endday;
|
this.endday = endday;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.startyear = startyear;
|
this.startyear = startyear;
|
||||||
this.endyear = endyear;
|
this.endyear = endyear;
|
||||||
|
this.number = number;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@@ -42,4 +44,6 @@ public class Semester
|
|||||||
public int getEndyear() {
|
public int getEndyear() {
|
||||||
return endyear;
|
return endyear;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getNumber(){return number; }
|
||||||
}
|
}
|
||||||
+37
-11
@@ -40,11 +40,11 @@ public class EntriesController
|
|||||||
for (int i = 0; i < 6; i++) {
|
for (int i = 0; i < 6; i++) {
|
||||||
var idx = 0;
|
var idx = 0;
|
||||||
for (int j = 0; j < 20; j++) {
|
for (int j = 0; j < 20; j++) {
|
||||||
if (lonelyEntry[i][j] != null){
|
if (lonelyEntry != null && lonelyEntry[i][j] != null){
|
||||||
combinedEntry[i][idx] = lonelyEntry[i][j];
|
combinedEntry[i][idx] = lonelyEntry[i][j];
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
if (happyEntry[i][j] != null){
|
if (happyEntry != null && happyEntry[i][j] != null){
|
||||||
combinedEntry[i][idx] = happyEntry[i][j];
|
combinedEntry[i][idx] = happyEntry[i][j];
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
@@ -59,23 +59,49 @@ public class EntriesController
|
|||||||
}
|
}
|
||||||
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@GetMapping("/entries/planned")
|
@GetMapping("/entries/all")
|
||||||
public ResponseEntity<Integer[]> getEntries(@RequestParam(name = "semesterid") int semesterid,
|
public ResponseEntity<Entry[]> getAllEntries(@RequestParam(name = "sessionid") String sessionid)
|
||||||
@RequestParam(name = "sessionid") String sessionid)
|
|
||||||
{
|
{
|
||||||
User sessionUser = UserSessionIDHandler.getUserBySessionID(sessionid);
|
User sessionUser = UserSessionIDHandler.getUserBySessionID(sessionid);
|
||||||
if (sessionUser != null)
|
if (sessionUser != null)
|
||||||
{
|
{
|
||||||
var entries = db.getAllEntries(semesterid, sessionUser.getId());
|
var entries = db.getAllEntries();
|
||||||
var count = 0;
|
|
||||||
for (int i = 0; i < entries.length; i++) {
|
return new ResponseEntity<>(entries, HttpStatus.OK);
|
||||||
count += entries[i].getTimeend()-entries[i].getTimestart();
|
|
||||||
}
|
|
||||||
return new ResponseEntity<>(new Integer[]{count}, HttpStatus.OK);
|
|
||||||
}
|
}
|
||||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CrossOrigin
|
||||||
|
@GetMapping("/entries/all/module")
|
||||||
|
public ResponseEntity<Entry[]> getAllEntriesModule(@RequestParam(name="sessionid") String sessionid, @RequestParam(name="moduleid") int moduleid)
|
||||||
|
{
|
||||||
|
User sessionUser = UserSessionIDHandler.getUserBySessionID(sessionid);
|
||||||
|
if (sessionUser != null)
|
||||||
|
{
|
||||||
|
return new ResponseEntity<>(db.getAllEntriesModule(moduleid), HttpStatus.OK);
|
||||||
|
}
|
||||||
|
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
|
// @CrossOrigin
|
||||||
|
// @GetMapping("/entries")
|
||||||
|
// public ResponseEntity<Integer[]> getEntries(@RequestParam(name = "semesterid") int semesterid,
|
||||||
|
// @RequestParam(name = "sessionid") String sessionid)
|
||||||
|
// {
|
||||||
|
// User sessionUser = UserSessionIDHandler.getUserBySessionID(sessionid);
|
||||||
|
// if (sessionUser != null)
|
||||||
|
// {
|
||||||
|
// var entries = db.getAllEntries(semesterid, sessionUser.getId());
|
||||||
|
// var count = 0;
|
||||||
|
// for (int i = 0; i < entries.length; i++) {
|
||||||
|
// count += entries[i].getTimeend()-entries[i].getTimestart();
|
||||||
|
// }
|
||||||
|
// return new ResponseEntity<>(new Integer[]{count}, HttpStatus.OK);
|
||||||
|
// }
|
||||||
|
// return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||||
|
// }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
POST
|
POST
|
||||||
A new entry to the database. Every user except of admins is allowed
|
A new entry to the database. Every user except of admins is allowed
|
||||||
|
|||||||
@@ -53,29 +53,23 @@ public class ModuleController
|
|||||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
GET
|
|
||||||
Get A Module by the matching semester and user id (important for edit function in frontend)
|
|
||||||
*/
|
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@GetMapping("/module/suid")
|
@GetMapping("/module/bysemesterid")
|
||||||
public ResponseEntity<Module[]> getModulesBySemesterUserID(@RequestParam(name = "sessionid") String sessionid, @RequestParam(name = "userid") String userid, @RequestParam(name = "semesterid") int semesterid)
|
public ResponseEntity<Module[]> getModulesBySemesterID(@RequestParam(name="sessionid") String sessionID, @RequestParam(name="semesterid") int semesterid)
|
||||||
{
|
{
|
||||||
User user = UserSessionIDHandler.getUserBySessionID(sessionid);
|
User user = UserSessionIDHandler.getUserBySessionID(sessionID);
|
||||||
String[] userIDSSplit = userid.split("a");
|
|
||||||
int[] userIDS = new int[userIDSSplit.length];
|
|
||||||
for(int i = 0; i < userIDS.length; i++)
|
|
||||||
{
|
|
||||||
userIDS[i] = Integer.parseInt(userIDSSplit[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if(user != null && user.getPermissions() == UserPermissions.admin.getValue())
|
if(user != null && user.getPermissions() == UserPermissions.admin.getValue())
|
||||||
{
|
{
|
||||||
|
Module[] tempModuleArray = db.getAllModules();
|
||||||
List<Module> result = new ArrayList<>();
|
List<Module> result = new ArrayList<>();
|
||||||
|
|
||||||
for(int i = 0; i < userIDS.length; i++)
|
for(int i = 0; i < tempModuleArray.length; i++)
|
||||||
{
|
{
|
||||||
result.add(db.getModuleBySemesterUserID(userIDS[i], semesterid));
|
if(tempModuleArray[i].getsemesterid() == semesterid)
|
||||||
|
{
|
||||||
|
result.add(tempModuleArray[i]);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(result.toArray(new Module[0]), HttpStatus.OK);
|
return new ResponseEntity<>(result.toArray(new Module[0]), HttpStatus.OK);
|
||||||
@@ -105,6 +99,7 @@ public class ModuleController
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
POST
|
POST
|
||||||
a new module entry. (When a user is selected in a semester.)
|
a new module entry. (When a user is selected in a semester.)
|
||||||
@@ -114,7 +109,6 @@ public class ModuleController
|
|||||||
public ResponseEntity<Module> addModule(@RequestBody Module module, @RequestParam(name = "sessionid") String sessionID)
|
public ResponseEntity<Module> addModule(@RequestBody Module module, @RequestParam(name = "sessionid") String sessionID)
|
||||||
{
|
{
|
||||||
|
|
||||||
System.out.println("test1");
|
|
||||||
User user = UserSessionIDHandler.getUserBySessionID(sessionID);
|
User user = UserSessionIDHandler.getUserBySessionID(sessionID);
|
||||||
|
|
||||||
if (user.getPermissions() == UserPermissions.admin.getValue())
|
if (user.getPermissions() == UserPermissions.admin.getValue())
|
||||||
@@ -150,25 +144,39 @@ public class ModuleController
|
|||||||
{
|
{
|
||||||
return new ResponseEntity<>(m, HttpStatus.OK);
|
return new ResponseEntity<>(m, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CrossOrigin
|
||||||
|
@PutMapping("/module/submit")
|
||||||
|
public ResponseEntity<Module> submitModule(@RequestParam(name="sessionid") String sessionID, @RequestParam(name="id") int id)
|
||||||
|
{
|
||||||
|
User u = UserSessionIDHandler.getUserBySessionID(sessionID);
|
||||||
|
if (u != null)
|
||||||
|
{
|
||||||
|
db.submitModule(id);
|
||||||
|
|
||||||
|
return new ResponseEntity<>(null, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
|
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
DELETE
|
DELETE
|
||||||
Delete A Module
|
Delete A Module
|
||||||
*/
|
*/
|
||||||
@CrossOrigin
|
@CrossOrigin
|
||||||
@DeleteMapping("/module")
|
@DeleteMapping("/module")
|
||||||
public void deleteModule(@RequestParam(name = "sessionid") String sessionid, @RequestParam(name = "semesterid") int semesterid, @RequestParam(name = "userid") int userid)
|
public void deleteModule(@RequestParam(name = "sessionid") String sessionid, @RequestParam(name="id") int id)
|
||||||
{
|
{
|
||||||
User u = UserSessionIDHandler.getUserBySessionID(sessionid);
|
User u = UserSessionIDHandler.getUserBySessionID(sessionid);
|
||||||
if (u != null && u.getPermissions() == UserPermissions.admin.getValue())
|
if (u != null && u.getPermissions() == UserPermissions.admin.getValue())
|
||||||
{
|
{
|
||||||
db.deleteModule(semesterid, userid);
|
db.deleteModule(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ public class SemesterController
|
|||||||
return new ResponseEntity<>(s, HttpStatus.OK);
|
return new ResponseEntity<>(s, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
return new ResponseEntity<>(null, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,3 @@
|
|||||||
|
artifactId=backend
|
||||||
|
groupId=com.example
|
||||||
|
version=0.0.1-SNAPSHOT
|
||||||
Whitespace-only changes.
+17
@@ -0,0 +1,17 @@
|
|||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\anwprj\controller\EntriesController.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\discard\WeekController.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\BackendApplication.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\anwprj\controller\ModuleController.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\anwprj\Users\UserSessionIDHandler.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\anwprj\controller\UserController.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\discard\Week\Week.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\discard\Encryption\RSA.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\anwprj\Users\User.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\anwprj\Semesters\Semester.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\anwprj\Users\UserPermissions.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\discard\Days\Day.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\anwprj\controller\SemesterController.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\anwprj\Entries\Entry.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\anwprj\Module\Module.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\discard\DayController.java
|
||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\main\java\com\example\backend\anwprj\Database\DataBaseHandler.java
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
com\example\backend\BackendApplicationTests.class
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
D:\DH\TIF22A_AnwProjekt_B\backend\src\test\java\com\example\backend\BackendApplicationTests.java
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
# Created at 2023-06-07T22:11:58.299
|
||||||
|
System.exit() or native command error interrupted process checker.
|
||||||
|
java.lang.IllegalStateException: error [STOPPED] to read process 132
|
||||||
|
at org.apache.maven.surefire.booter.PpidChecker.checkProcessInfo(PpidChecker.java:145)
|
||||||
|
at org.apache.maven.surefire.booter.PpidChecker.isProcessAlive(PpidChecker.java:116)
|
||||||
|
at org.apache.maven.surefire.booter.ForkedBooter$2.run(ForkedBooter.java:214)
|
||||||
|
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:577)
|
||||||
|
at java.base/java.util.concurrent.FutureTask.runAndReset(FutureTask.java:358)
|
||||||
|
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:305)
|
||||||
|
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1144)
|
||||||
|
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:642)
|
||||||
|
at java.base/java.lang.Thread.run(Thread.java:1623)
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<testsuite xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="https://maven.apache.org/surefire/maven-surefire-plugin/xsd/surefire-test-report.xsd" name="com.example.backend.BackendApplicationTests" time="3.552" tests="1" errors="0" skipped="0" failures="0">
|
||||||
|
<properties>
|
||||||
|
<property name="java.specification.version" value="20"/>
|
||||||
|
<property name="sun.cpu.isalist" value="amd64"/>
|
||||||
|
<property name="sun.jnu.encoding" value="Cp1252"/>
|
||||||
|
<property name="java.class.path" value="D:\DH\TIF22A_AnwProjekt_B\backend\target\test-classes;D:\DH\TIF22A_AnwProjekt_B\backend\target\classes;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-starter-web\3.0.6\spring-boot-starter-web-3.0.6.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-starter\3.0.6\spring-boot-starter-3.0.6.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot\3.0.6\spring-boot-3.0.6.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\3.0.6\spring-boot-autoconfigure-3.0.6.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-starter-logging\3.0.6\spring-boot-starter-logging-3.0.6.jar;C:\Users\braus\.m2\repository\ch\qos\logback\logback-classic\1.4.7\logback-classic-1.4.7.jar;C:\Users\braus\.m2\repository\ch\qos\logback\logback-core\1.4.7\logback-core-1.4.7.jar;C:\Users\braus\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.19.0\log4j-to-slf4j-2.19.0.jar;C:\Users\braus\.m2\repository\org\apache\logging\log4j\log4j-api\2.19.0\log4j-api-2.19.0.jar;C:\Users\braus\.m2\repository\org\slf4j\jul-to-slf4j\2.0.7\jul-to-slf4j-2.0.7.jar;C:\Users\braus\.m2\repository\jakarta\annotation\jakarta.annotation-api\2.1.1\jakarta.annotation-api-2.1.1.jar;C:\Users\braus\.m2\repository\org\yaml\snakeyaml\1.33\snakeyaml-1.33.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-starter-json\3.0.6\spring-boot-starter-json-3.0.6.jar;C:\Users\braus\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.14.2\jackson-databind-2.14.2.jar;C:\Users\braus\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.14.2\jackson-annotations-2.14.2.jar;C:\Users\braus\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.14.2\jackson-core-2.14.2.jar;C:\Users\braus\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.14.2\jackson-datatype-jdk8-2.14.2.jar;C:\Users\braus\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.14.2\jackson-datatype-jsr310-2.14.2.jar;C:\Users\braus\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.14.2\jackson-module-parameter-names-2.14.2.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\3.0.6\spring-boot-starter-tomcat-3.0.6.jar;C:\Users\braus\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\10.1.8\tomcat-embed-core-10.1.8.jar;C:\Users\braus\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\10.1.8\tomcat-embed-el-10.1.8.jar;C:\Users\braus\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\10.1.8\tomcat-embed-websocket-10.1.8.jar;C:\Users\braus\.m2\repository\org\springframework\spring-web\6.0.8\spring-web-6.0.8.jar;C:\Users\braus\.m2\repository\org\springframework\spring-beans\6.0.8\spring-beans-6.0.8.jar;C:\Users\braus\.m2\repository\io\micrometer\micrometer-observation\1.10.6\micrometer-observation-1.10.6.jar;C:\Users\braus\.m2\repository\io\micrometer\micrometer-commons\1.10.6\micrometer-commons-1.10.6.jar;C:\Users\braus\.m2\repository\org\springframework\spring-webmvc\6.0.8\spring-webmvc-6.0.8.jar;C:\Users\braus\.m2\repository\org\springframework\spring-aop\6.0.8\spring-aop-6.0.8.jar;C:\Users\braus\.m2\repository\org\springframework\spring-context\6.0.8\spring-context-6.0.8.jar;C:\Users\braus\.m2\repository\org\springframework\spring-expression\6.0.8\spring-expression-6.0.8.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-starter-test\3.0.6\spring-boot-starter-test-3.0.6.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-test\3.0.6\spring-boot-test-3.0.6.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-test-autoconfigure\3.0.6\spring-boot-test-autoconfigure-3.0.6.jar;C:\Users\braus\.m2\repository\com\jayway\jsonpath\json-path\2.7.0\json-path-2.7.0.jar;C:\Users\braus\.m2\repository\net\minidev\json-smart\2.4.10\json-smart-2.4.10.jar;C:\Users\braus\.m2\repository\net\minidev\accessors-smart\2.4.9\accessors-smart-2.4.9.jar;C:\Users\braus\.m2\repository\org\ow2\asm\asm\9.3\asm-9.3.jar;C:\Users\braus\.m2\repository\org\slf4j\slf4j-api\2.0.7\slf4j-api-2.0.7.jar;C:\Users\braus\.m2\repository\jakarta\xml\bind\jakarta.xml.bind-api\4.0.0\jakarta.xml.bind-api-4.0.0.jar;C:\Users\braus\.m2\repository\jakarta\activation\jakarta.activation-api\2.1.1\jakarta.activation-api-2.1.1.jar;C:\Users\braus\.m2\repository\org\assertj\assertj-core\3.23.1\assertj-core-3.23.1.jar;C:\Users\braus\.m2\repository\net\bytebuddy\byte-buddy\1.12.23\byte-buddy-1.12.23.jar;C:\Users\braus\.m2\repository\org\hamcrest\hamcrest\2.2\hamcrest-2.2.jar;C:\Users\braus\.m2\repository\org\junit\jupiter\junit-jupiter\5.9.2\junit-jupiter-5.9.2.jar;C:\Users\braus\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.9.2\junit-jupiter-api-5.9.2.jar;C:\Users\braus\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\braus\.m2\repository\org\junit\platform\junit-platform-commons\1.9.2\junit-plLine truncated
|
||||||
|
<property name="java.vm.vendor" value="Oracle Corporation"/>
|
||||||
|
<property name="sun.arch.data.model" value="64"/>
|
||||||
|
<property name="user.variant" value=""/>
|
||||||
|
<property name="java.vendor.url" value="https://java.oracle.com/"/>
|
||||||
|
<property name="user.timezone" value="Europe/Berlin"/>
|
||||||
|
<property name="os.name" value="Windows 10"/>
|
||||||
|
<property name="java.vm.specification.version" value="20"/>
|
||||||
|
<property name="sun.java.launcher" value="SUN_STANDARD"/>
|
||||||
|
<property name="user.country" value="DE"/>
|
||||||
|
<property name="sun.boot.library.path" value="C:\Program Files\Java\jdk-20\bin"/>
|
||||||
|
<property name="sun.java.command" value="C:\Users\braus\AppData\Local\Temp\surefire15225856924068768135\surefirebooter10166169173719473359.jar C:\Users\braus\AppData\Local\Temp\surefire15225856924068768135 2023-06-09T22-50-22_049-jvmRun1 surefire10641026690989140399tmp surefire_017224228111119904739tmp"/>
|
||||||
|
<property name="jdk.debug" value="release"/>
|
||||||
|
<property name="surefire.test.class.path" value="D:\DH\TIF22A_AnwProjekt_B\backend\target\test-classes;D:\DH\TIF22A_AnwProjekt_B\backend\target\classes;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-starter-web\3.0.6\spring-boot-starter-web-3.0.6.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-starter\3.0.6\spring-boot-starter-3.0.6.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot\3.0.6\spring-boot-3.0.6.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-autoconfigure\3.0.6\spring-boot-autoconfigure-3.0.6.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-starter-logging\3.0.6\spring-boot-starter-logging-3.0.6.jar;C:\Users\braus\.m2\repository\ch\qos\logback\logback-classic\1.4.7\logback-classic-1.4.7.jar;C:\Users\braus\.m2\repository\ch\qos\logback\logback-core\1.4.7\logback-core-1.4.7.jar;C:\Users\braus\.m2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.19.0\log4j-to-slf4j-2.19.0.jar;C:\Users\braus\.m2\repository\org\apache\logging\log4j\log4j-api\2.19.0\log4j-api-2.19.0.jar;C:\Users\braus\.m2\repository\org\slf4j\jul-to-slf4j\2.0.7\jul-to-slf4j-2.0.7.jar;C:\Users\braus\.m2\repository\jakarta\annotation\jakarta.annotation-api\2.1.1\jakarta.annotation-api-2.1.1.jar;C:\Users\braus\.m2\repository\org\yaml\snakeyaml\1.33\snakeyaml-1.33.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-starter-json\3.0.6\spring-boot-starter-json-3.0.6.jar;C:\Users\braus\.m2\repository\com\fasterxml\jackson\core\jackson-databind\2.14.2\jackson-databind-2.14.2.jar;C:\Users\braus\.m2\repository\com\fasterxml\jackson\core\jackson-annotations\2.14.2\jackson-annotations-2.14.2.jar;C:\Users\braus\.m2\repository\com\fasterxml\jackson\core\jackson-core\2.14.2\jackson-core-2.14.2.jar;C:\Users\braus\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.14.2\jackson-datatype-jdk8-2.14.2.jar;C:\Users\braus\.m2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.14.2\jackson-datatype-jsr310-2.14.2.jar;C:\Users\braus\.m2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.14.2\jackson-module-parameter-names-2.14.2.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-starter-tomcat\3.0.6\spring-boot-starter-tomcat-3.0.6.jar;C:\Users\braus\.m2\repository\org\apache\tomcat\embed\tomcat-embed-core\10.1.8\tomcat-embed-core-10.1.8.jar;C:\Users\braus\.m2\repository\org\apache\tomcat\embed\tomcat-embed-el\10.1.8\tomcat-embed-el-10.1.8.jar;C:\Users\braus\.m2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\10.1.8\tomcat-embed-websocket-10.1.8.jar;C:\Users\braus\.m2\repository\org\springframework\spring-web\6.0.8\spring-web-6.0.8.jar;C:\Users\braus\.m2\repository\org\springframework\spring-beans\6.0.8\spring-beans-6.0.8.jar;C:\Users\braus\.m2\repository\io\micrometer\micrometer-observation\1.10.6\micrometer-observation-1.10.6.jar;C:\Users\braus\.m2\repository\io\micrometer\micrometer-commons\1.10.6\micrometer-commons-1.10.6.jar;C:\Users\braus\.m2\repository\org\springframework\spring-webmvc\6.0.8\spring-webmvc-6.0.8.jar;C:\Users\braus\.m2\repository\org\springframework\spring-aop\6.0.8\spring-aop-6.0.8.jar;C:\Users\braus\.m2\repository\org\springframework\spring-context\6.0.8\spring-context-6.0.8.jar;C:\Users\braus\.m2\repository\org\springframework\spring-expression\6.0.8\spring-expression-6.0.8.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-starter-test\3.0.6\spring-boot-starter-test-3.0.6.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-test\3.0.6\spring-boot-test-3.0.6.jar;C:\Users\braus\.m2\repository\org\springframework\boot\spring-boot-test-autoconfigure\3.0.6\spring-boot-test-autoconfigure-3.0.6.jar;C:\Users\braus\.m2\repository\com\jayway\jsonpath\json-path\2.7.0\json-path-2.7.0.jar;C:\Users\braus\.m2\repository\net\minidev\json-smart\2.4.10\json-smart-2.4.10.jar;C:\Users\braus\.m2\repository\net\minidev\accessors-smart\2.4.9\accessors-smart-2.4.9.jar;C:\Users\braus\.m2\repository\org\ow2\asm\asm\9.3\asm-9.3.jar;C:\Users\braus\.m2\repository\org\slf4j\slf4j-api\2.0.7\slf4j-api-2.0.7.jar;C:\Users\braus\.m2\repository\jakarta\xml\bind\jakarta.xml.bind-api\4.0.0\jakarta.xml.bind-api-4.0.0.jar;C:\Users\braus\.m2\repository\jakarta\activation\jakarta.activation-api\2.1.1\jakarta.activation-api-2.1.1.jar;C:\Users\braus\.m2\repository\org\assertj\assertj-core\3.23.1\assertj-core-3.23.1.jar;C:\Users\braus\.m2\repository\net\bytebuddy\byte-buddy\1.12.23\byte-buddy-1.12.23.jar;C:\Users\braus\.m2\repository\org\hamcrest\hamcrest\2.2\hamcrest-2.2.jar;C:\Users\braus\.m2\repository\org\junit\jupiter\junit-jupiter\5.9.2\junit-jupiter-5.9.2.jar;C:\Users\braus\.m2\repository\org\junit\jupiter\junit-jupiter-api\5.9.2\junit-jupiter-api-5.9.2.jar;C:\Users\braus\.m2\repository\org\opentest4j\opentest4j\1.2.0\opentest4j-1.2.0.jar;C:\Users\braus\.m2\repository\org\junit\platform\junit-platform-commons\1.9.2Line truncated
|
||||||
|
<property name="sun.cpu.endian" value="little"/>
|
||||||
|
<property name="user.home" value="C:\Users\braus"/>
|
||||||
|
<property name="user.language" value="de"/>
|
||||||
|
<property name="java.specification.vendor" value="Oracle Corporation"/>
|
||||||
|
<property name="java.version.date" value="2023-03-21"/>
|
||||||
|
<property name="java.home" value="C:\Program Files\Java\jdk-20"/>
|
||||||
|
<property name="file.separator" value="\"/>
|
||||||
|
<property name="basedir" value="D:\DH\TIF22A_AnwProjekt_B\backend"/>
|
||||||
|
<property name="java.vm.compressedOopsMode" value="Zero based"/>
|
||||||
|
<property name="line.separator" value=" "/>
|
||||||
|
<property name="java.vm.specification.vendor" value="Oracle Corporation"/>
|
||||||
|
<property name="java.specification.name" value="Java Platform API Specification"/>
|
||||||
|
<property name="surefire.real.class.path" value="C:\Users\braus\AppData\Local\Temp\surefire15225856924068768135\surefirebooter10166169173719473359.jar"/>
|
||||||
|
<property name="user.script" value=""/>
|
||||||
|
<property name="sun.management.compiler" value="HotSpot 64-Bit Tiered Compilers"/>
|
||||||
|
<property name="java.runtime.version" value="20+36-2344"/>
|
||||||
|
<property name="user.name" value="braus"/>
|
||||||
|
<property name="stdout.encoding" value="Cp1252"/>
|
||||||
|
<property name="path.separator" value=";"/>
|
||||||
|
<property name="os.version" value="10.0"/>
|
||||||
|
<property name="java.runtime.name" value="Java(TM) SE Runtime Environment"/>
|
||||||
|
<property name="file.encoding" value="UTF-8"/>
|
||||||
|
<property name="java.vm.name" value="Java HotSpot(TM) 64-Bit Server VM"/>
|
||||||
|
<property name="localRepository" value="C:\Users\braus\.m2\repository"/>
|
||||||
|
<property name="java.vendor.url.bug" value="https://bugreport.java.com/bugreport/"/>
|
||||||
|
<property name="java.io.tmpdir" value="C:\Users\braus\AppData\Local\Temp\"/>
|
||||||
|
<property name="idea.version" value="2023.1"/>
|
||||||
|
<property name="java.version" value="20"/>
|
||||||
|
<property name="user.dir" value="D:\DH\TIF22A_AnwProjekt_B\backend"/>
|
||||||
|
<property name="os.arch" value="amd64"/>
|
||||||
|
<property name="java.vm.specification.name" value="Java Virtual Machine Specification"/>
|
||||||
|
<property name="sun.os.patch.level" value=""/>
|
||||||
|
<property name="native.encoding" value="Cp1252"/>
|
||||||
|
<property name="java.library.path" value="C:\Program Files\Java\jdk-20\bin;C:\Windows\Sun\Java\bin;C:\Windows\system32;C:\Windows;C:\Program Files (x86)\VMware\VMware Player\bin\;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Program Files\dotnet\;C:\Program Files (x86)\Bitvise SSH Client;C:\Program Files\swipl\bin;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Program Files\Docker\Docker\resources\bin;C:\Users\braus\AppData\Local\Microsoft\WindowsApps;C:\Users\braus\AppData\Local\GitHubDesktop\bin;C:\Users\braus\AppData\Local\JetBrains\Toolbox\scripts;C:\Users\braus\.dotnet\tools;C:\Users\braus\AppData\Local\gitkraken\bin;C:\Users\braus\AppData\Roaming\npm;."/>
|
||||||
|
<property name="java.vm.info" value="mixed mode, sharing"/>
|
||||||
|
<property name="stderr.encoding" value="Cp1252"/>
|
||||||
|
<property name="java.vendor" value="Oracle Corporation"/>
|
||||||
|
<property name="java.vm.version" value="20+36-2344"/>
|
||||||
|
<property name="sun.io.unicode.encoding" value="UnicodeLittle"/>
|
||||||
|
<property name="java.class.version" value="64.0"/>
|
||||||
|
</properties>
|
||||||
|
<testcase name="contextLoads" classname="com.example.backend.BackendApplicationTests" time="0.649"/>
|
||||||
|
</testsuite>
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Test set: com.example.backend.BackendApplicationTests
|
||||||
|
-------------------------------------------------------------------------------
|
||||||
|
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 3.552 s - in com.example.backend.BackendApplicationTests
|
||||||
Binary file not shown.
-15
@@ -1,15 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "TIF22A_AnwProjekt_B",
|
|
||||||
"lockfileVersion": 3,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {
|
|
||||||
"node_modules/feiertagejs": {
|
|
||||||
"version": "1.3.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/feiertagejs/-/feiertagejs-1.3.9.tgz",
|
|
||||||
"integrity": "sha512-tUP+WBv2OWBhPwe3NfqwCtjMq+ym598a42tfqmL0FySswEb9xs96p2iKwqqx+lxKieu1njJBRZKsFm92bJhxZw==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
The MIT License (MIT)
|
|
||||||
|
|
||||||
Copyright (c) 2015 Simon Fakir
|
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
|
||||||
in the Software without restriction, including without limitation the rights
|
|
||||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
||||||
copies of the Software, and to permit persons to whom the Software is
|
|
||||||
furnished to do so, subject to the following conditions:
|
|
||||||
|
|
||||||
The above copyright notice and this permission notice shall be included in all
|
|
||||||
copies or substantial portions of the Software.
|
|
||||||
|
|
||||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
||||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
||||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
||||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
||||||
SOFTWARE.
|
|
||||||
|
|
||||||
-93
@@ -1,93 +0,0 @@
|
|||||||
# Feiertage.js
|
|
||||||
|
|
||||||
[](https://badge.fury.io/js/feiertagejs)
|
|
||||||
[](https://travis-ci.org/sfakir/feiertagejs)
|
|
||||||
|
|
||||||
|
|
||||||
Feiertage.js is a small *typescript* npm module without dependencies to calculate German holidays for each Bundesland.
|
|
||||||
|
|
||||||
## Installation
|
|
||||||
|
|
||||||
- [yarn](https://yarnpkg.com/en/): `yarn add feiertagejs`
|
|
||||||
- [npm](https://www.npmjs.com/): `npm install feiertagejs`
|
|
||||||
- [bower](https://bower.io/): `bower install feiertagejs` *outdated!*
|
|
||||||
- [Plain Javascript](http://extern.fakir.it/feiertagejs/feiertagejs.zip) *outdated!*
|
|
||||||
|
|
||||||
## Quick Examples
|
|
||||||
|
|
||||||
### ES Modules (Typescript/Javasript)
|
|
||||||
|
|
||||||
The prefered whay is to directly import the typescript module. However, you can also use .js.
|
|
||||||
Please find here some examples and full api [here](docs.md).
|
|
||||||
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
import { getHolidays, isHoliday, isSpecificHoliday } from 'feiertagejs';
|
|
||||||
|
|
||||||
const today = new Date();
|
|
||||||
|
|
||||||
console.log(isHoliday(today, 'BW'));
|
|
||||||
// probably false, because you are working ;)
|
|
||||||
|
|
||||||
// check if a day is a specific holiday:
|
|
||||||
console.log(isSpecificHoliday(today, 'CHRISTIHIMMELFAHRT','ALL'));
|
|
||||||
|
|
||||||
// get all holiday for a single year: getHolidays()
|
|
||||||
// returns an array of "Holiday" Objects. Please see the docs.md for all properties.
|
|
||||||
const holidays2023 = getHolidays('2023','BUND');
|
|
||||||
|
|
||||||
|
|
||||||
console.log('date', holidays2023[0].date); // = Date("2023-01-01");
|
|
||||||
console.log('name', holidays2023[0].name); // 'NEUJAHRSTAG' (constant)
|
|
||||||
console.log('translation', holidays2023[0].trans('de')); // German translation: Neujahrstag
|
|
||||||
console.log('equals?', holidays2023[0].equals(date)); // Compare days only (ignore time)
|
|
||||||
```
|
|
||||||
|
|
||||||
### Usage in Node.js
|
|
||||||
|
|
||||||
```javascript
|
|
||||||
var feiertagejs = require('feiertagejs');
|
|
||||||
|
|
||||||
var today = new Date();
|
|
||||||
|
|
||||||
console.log(feiertagejs.isHoliday(today, 'BW'));
|
|
||||||
// probably false, because you are working ;)
|
|
||||||
|
|
||||||
// check if a day is a specific holiday:
|
|
||||||
console.log(feiertagejs.isSpecificHoliday(today, 'CHRISTIHIMMELFAHRT'));
|
|
||||||
|
|
||||||
// get all holiday for a single year: getHolidays()
|
|
||||||
// returns an array of "Holiday" Objects. Please see the docs.md for all properties.
|
|
||||||
|
|
||||||
var holidays2023 = feiertagejs.getHolidays('2023', 'BUND');
|
|
||||||
|
|
||||||
console.log('date', holidays2023[0].date); // = Date("2023-01-01");
|
|
||||||
console.log('name', holidays2023[0].name); // 'NEUJAHRSTAG' (constant)
|
|
||||||
console.log('translation', holidays2023[0].translate()); // German translation: Neujahrstag
|
|
||||||
console.log('equals?', holidays2023[0].equals(date)); // Compare days only (ignore time)
|
|
||||||
```
|
|
||||||
|
|
||||||
## API doc
|
|
||||||
|
|
||||||
The full API doc can be found [here](docs.md).
|
|
||||||
|
|
||||||
|
|
||||||
## Feedback and Questions
|
|
||||||
|
|
||||||
You have two options two give feedback or ask questions:
|
|
||||||
|
|
||||||
* Comment the official release [post](https://fakir.tech/de/feiertage-js-deutsche-feiertage-fuer-node-js-und-browser-javascript/)
|
|
||||||
* Open issues or pullrequests on [github](https://github.com/sfakir/feiertagejs)
|
|
||||||
|
|
||||||
|
|
||||||
## Contributors
|
|
||||||
|
|
||||||
Thank you for contributing:
|
|
||||||
|
|
||||||
* thetric
|
|
||||||
* SteveOswald
|
|
||||||
|
|
||||||
|
|
||||||
## Feedback
|
|
||||||
|
|
||||||
If you have any questions, feel free to open an issue.
|
|
||||||
-476
@@ -1,476 +0,0 @@
|
|||||||
const germanTranslations = {
|
|
||||||
NEUJAHRSTAG: 'Neujahrstag',
|
|
||||||
HEILIGEDREIKOENIGE: 'Heilige Drei Könige',
|
|
||||||
KARFREITAG: 'Karfreitag',
|
|
||||||
OSTERSONNTAG: 'Ostersonntag',
|
|
||||||
OSTERMONTAG: 'Ostermontag',
|
|
||||||
TAG_DER_ARBEIT: 'Tag der Arbeit',
|
|
||||||
CHRISTIHIMMELFAHRT: 'Christi Himmelfahrt',
|
|
||||||
PFINGSTSONNTAG: 'Pfingstsonntag',
|
|
||||||
PFINGSTMONTAG: 'Pfingstmontag',
|
|
||||||
FRONLEICHNAM: 'Fronleichnam',
|
|
||||||
MARIAHIMMELFAHRT: 'Mariä Himmelfahrt',
|
|
||||||
DEUTSCHEEINHEIT: 'Tag der Deutschen Einheit',
|
|
||||||
REFORMATIONSTAG: 'Reformationstag',
|
|
||||||
ALLERHEILIGEN: 'Allerheiligen',
|
|
||||||
BUBETAG: 'Buß- und Bettag',
|
|
||||||
ERSTERWEIHNACHTSFEIERTAG: '1. Weihnachtstag',
|
|
||||||
ZWEITERWEIHNACHTSFEIERTAG: '2. Weihnachtstag',
|
|
||||||
WELTKINDERTAG: 'Weltkindertag',
|
|
||||||
WELTFRAUENTAG: 'Weltfrauentag',
|
|
||||||
AUGSBURGER_FRIEDENSFEST: 'Augsburger Friedensfest',
|
|
||||||
};
|
|
||||||
|
|
||||||
const allHolidays = [
|
|
||||||
'NEUJAHRSTAG',
|
|
||||||
'HEILIGEDREIKOENIGE',
|
|
||||||
'KARFREITAG',
|
|
||||||
'OSTERSONNTAG',
|
|
||||||
'OSTERMONTAG',
|
|
||||||
'TAG_DER_ARBEIT',
|
|
||||||
'CHRISTIHIMMELFAHRT',
|
|
||||||
'MARIAHIMMELFAHRT',
|
|
||||||
'PFINGSTSONNTAG',
|
|
||||||
'PFINGSTMONTAG',
|
|
||||||
'FRONLEICHNAM',
|
|
||||||
'DEUTSCHEEINHEIT',
|
|
||||||
'REFORMATIONSTAG',
|
|
||||||
'ALLERHEILIGEN',
|
|
||||||
'BUBETAG',
|
|
||||||
'ERSTERWEIHNACHTSFEIERTAG',
|
|
||||||
'ZWEITERWEIHNACHTSFEIERTAG',
|
|
||||||
'WELTKINDERTAG',
|
|
||||||
'WELTFRAUENTAG',
|
|
||||||
'AUGSBURGER_FRIEDENSFEST',
|
|
||||||
];
|
|
||||||
|
|
||||||
const allRegions = [
|
|
||||||
'BW',
|
|
||||||
'BY',
|
|
||||||
'BE',
|
|
||||||
'BB',
|
|
||||||
'HB',
|
|
||||||
'HE',
|
|
||||||
'HH',
|
|
||||||
'MV',
|
|
||||||
'NI',
|
|
||||||
'NW',
|
|
||||||
'RP',
|
|
||||||
'SL',
|
|
||||||
'SN',
|
|
||||||
'ST',
|
|
||||||
'SH',
|
|
||||||
'TH',
|
|
||||||
'BUND',
|
|
||||||
'AUGSBURG',
|
|
||||||
'ALL',
|
|
||||||
];
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* feiertage.js
|
|
||||||
* @repository https://github.com/sfakir/feiertagejs
|
|
||||||
* @docs https://github.com/sfakir/feiertagejs/blob/master/docs.md
|
|
||||||
*
|
|
||||||
* Copyright 2015-2021 Simon Fakir
|
|
||||||
* Released under the MIT license
|
|
||||||
*/
|
|
||||||
// translations
|
|
||||||
const defaultLanguage = 'de';
|
|
||||||
let currentLanguage = defaultLanguage;
|
|
||||||
const translations = {
|
|
||||||
de: germanTranslations,
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* adds a translation for the holidays (e.g. english).
|
|
||||||
* This also allows to override the German names.
|
|
||||||
* Hint: Interpolates German for missing translations
|
|
||||||
* @param {string} isoCode of the new language
|
|
||||||
* @param {TranslationTable} newTranslation map of {HolidayType} to translation stringg
|
|
||||||
*/
|
|
||||||
function addTranslation(isoCode, newTranslation) {
|
|
||||||
const code = isoCode.toLowerCase();
|
|
||||||
const defaultTranslation = translations[defaultLanguage];
|
|
||||||
let missingFields = false;
|
|
||||||
// fill new Translation with default Language
|
|
||||||
for (const holiday of allHolidays) {
|
|
||||||
if (!newTranslation[holiday]) {
|
|
||||||
missingFields = true;
|
|
||||||
newTranslation[holiday] = defaultTranslation[holiday];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (missingFields) {
|
|
||||||
console.warn('[feiertagejs] addTranslation: you did not add all holidays in your translation! Took German as fallback');
|
|
||||||
}
|
|
||||||
translations[code] = newTranslation;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set a language to default language
|
|
||||||
* @param {string} isoCode
|
|
||||||
*/
|
|
||||||
function setLanguage(isoCode) {
|
|
||||||
const code = isoCode.toLowerCase();
|
|
||||||
if (!translations[code]) {
|
|
||||||
throw new TypeError(`[feiertagejs] tried to set language to ${code} but the translation is missing. Please use addTranslation(isoCode,object) first`);
|
|
||||||
}
|
|
||||||
currentLanguage = isoCode;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get currently set language
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
function getLanguage() {
|
|
||||||
return currentLanguage;
|
|
||||||
}
|
|
||||||
// holidays api
|
|
||||||
/**
|
|
||||||
* Checks if a specific date is sunday or holiday.
|
|
||||||
* @param date
|
|
||||||
* @param region
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
function isSunOrHoliday(date, region) {
|
|
||||||
checkRegion(region);
|
|
||||||
return date.getDay() === 0 || isHoliday(date, region);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Check is specific date is holiday.
|
|
||||||
* @param date
|
|
||||||
* @param {Region} region two character {@link Region} code
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
function isHoliday(date, region) {
|
|
||||||
checkRegion(region);
|
|
||||||
const year = date.getFullYear();
|
|
||||||
const internalDate = toUtcTimestamp(date);
|
|
||||||
const holidays = getHolidaysAsUtcTimestamps(year, region);
|
|
||||||
return holidays.indexOf(internalDate) !== -1;
|
|
||||||
}
|
|
||||||
function getHolidayByDate(date, region = 'ALL') {
|
|
||||||
checkRegion(region);
|
|
||||||
const holidays = getHolidaysOfYear(date.getFullYear(), region);
|
|
||||||
return holidays.find((holiday) => holiday.equals(date));
|
|
||||||
}
|
|
||||||
// additional runtime checks
|
|
||||||
/**
|
|
||||||
* Checks if the given region is a valid {@link Region}.
|
|
||||||
*
|
|
||||||
* @param region {@link Region} to check
|
|
||||||
* @throws {Error}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function checkRegion(region) {
|
|
||||||
if (region === null || region === undefined) {
|
|
||||||
throw new Error(`Region must not be undefined or null`);
|
|
||||||
}
|
|
||||||
if (allRegions.indexOf(region) === -1) {
|
|
||||||
throw new Error(`Invalid region: ${region}! Must be one of ${allRegions.toString()}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Checks if the given holidayName is a valid {@link HolidayType}.
|
|
||||||
* @param holidayName {@link HolidayType} to check
|
|
||||||
* @throws {Error}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function checkHolidayType(holidayName) {
|
|
||||||
if (holidayName === null || holidayName === undefined) {
|
|
||||||
throw new TypeError('holidayName must not be null or undefined');
|
|
||||||
}
|
|
||||||
if (allHolidays.indexOf(holidayName) === -1) {
|
|
||||||
throw new Error(`feiertage.js: invalid holiday type "${holidayName}"! Must be one of ${allHolidays.toString()}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function isSpecificHoliday(date, holidayName, region = 'ALL') {
|
|
||||||
checkRegion(region);
|
|
||||||
checkHolidayType(holidayName);
|
|
||||||
const holidays = getHolidaysOfYear(date.getFullYear(), region);
|
|
||||||
const foundHoliday = holidays.find((holiday) => holiday.equals(date));
|
|
||||||
if (!foundHoliday) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return foundHoliday.name === holidayName;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns all holidays of a year in a {@link Region}.
|
|
||||||
* @param year
|
|
||||||
* @param region
|
|
||||||
* @returns {Array.<Holiday>}
|
|
||||||
*/
|
|
||||||
function getHolidays(year, region) {
|
|
||||||
let y;
|
|
||||||
if (typeof year === 'string') {
|
|
||||||
y = parseInt(year, 10);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
y = year;
|
|
||||||
}
|
|
||||||
checkRegion(region);
|
|
||||||
return getHolidaysOfYear(y, region);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {number} year
|
|
||||||
* @param region
|
|
||||||
* @returns {number[]}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getHolidaysAsUtcTimestamps(year, region) {
|
|
||||||
const holidays = getHolidaysOfYear(year, region);
|
|
||||||
return holidays.map((holiday) => toUtcTimestamp(holiday.date));
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {number} year
|
|
||||||
* @param region
|
|
||||||
* @returns {{objects: Array.<Holiday>, integers}}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getHolidaysOfYear(year, region) {
|
|
||||||
const easterDate = getEasterDate(year);
|
|
||||||
const karfreitag = addDays(new Date(easterDate.getTime()), -2);
|
|
||||||
const ostermontag = addDays(new Date(easterDate.getTime()), 1);
|
|
||||||
const christiHimmelfahrt = addDays(new Date(easterDate.getTime()), 39);
|
|
||||||
const pfingstsonntag = addDays(new Date(easterDate.getTime()), 49);
|
|
||||||
const pfingstmontag = addDays(new Date(easterDate.getTime()), 50);
|
|
||||||
const holidays = [
|
|
||||||
...getCommonHolidays(year),
|
|
||||||
newHoliday('KARFREITAG', karfreitag),
|
|
||||||
newHoliday('OSTERMONTAG', ostermontag),
|
|
||||||
newHoliday('CHRISTIHIMMELFAHRT', christiHimmelfahrt),
|
|
||||||
newHoliday('PFINGSTMONTAG', pfingstmontag),
|
|
||||||
];
|
|
||||||
addHeiligeDreiKoenige(year, region, holidays);
|
|
||||||
addEasterAndPfingsten(year, region, easterDate, pfingstsonntag, holidays);
|
|
||||||
addFronleichnam(region, easterDate, holidays);
|
|
||||||
addMariaeHimmelfahrt(year, region, holidays);
|
|
||||||
addReformationstag(year, region, holidays);
|
|
||||||
addAllerheiligen(year, region, holidays);
|
|
||||||
addBussUndBetttag(year, region, holidays);
|
|
||||||
addWeltkindertag(year, region, holidays);
|
|
||||||
addWeltfrauenTag(year, region, holidays);
|
|
||||||
addRegionalHolidays(year, region, holidays);
|
|
||||||
return holidays.sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
||||||
}
|
|
||||||
function getCommonHolidays(year) {
|
|
||||||
return [
|
|
||||||
newHoliday('NEUJAHRSTAG', makeDate(year, 1, 1)),
|
|
||||||
newHoliday('TAG_DER_ARBEIT', makeDate(year, 5, 1)),
|
|
||||||
newHoliday('DEUTSCHEEINHEIT', makeDate(year, 10, 3)),
|
|
||||||
newHoliday('ERSTERWEIHNACHTSFEIERTAG', makeDate(year, 12, 25)),
|
|
||||||
newHoliday('ZWEITERWEIHNACHTSFEIERTAG', makeDate(year, 12, 26)),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
function addRegionalHolidays(year, region, feiertageObjects) {
|
|
||||||
if (region === 'AUGSBURG') {
|
|
||||||
feiertageObjects.push(newHoliday('AUGSBURGER_FRIEDENSFEST', makeDate(year, 8, 8)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addHeiligeDreiKoenige(year, region, feiertageObjects) {
|
|
||||||
if (region === 'BW' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'ST' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
feiertageObjects.push(newHoliday('HEILIGEDREIKOENIGE', makeDate(year, 1, 6)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addEasterAndPfingsten(year, region, easterDate, pfingstsonntag, feiertageObjects) {
|
|
||||||
if (region === 'BB' || region === 'ALL') {
|
|
||||||
feiertageObjects.push(newHoliday('OSTERSONNTAG', easterDate), newHoliday('PFINGSTSONNTAG', pfingstsonntag));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addFronleichnam(region, easterDate, holidays) {
|
|
||||||
if (region === 'BW' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'HE' ||
|
|
||||||
region === 'NW' ||
|
|
||||||
region === 'RP' ||
|
|
||||||
region === 'SL' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
const fronleichnam = addDays(new Date(easterDate.getTime()), 60);
|
|
||||||
holidays.push(newHoliday('FRONLEICHNAM', fronleichnam));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addMariaeHimmelfahrt(year, region, holidays) {
|
|
||||||
if (region === 'SL' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
holidays.push(newHoliday('MARIAHIMMELFAHRT', makeDate(year, 8, 15)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addReformationstag(year, region, holidays) {
|
|
||||||
if (year === 2017 ||
|
|
||||||
region === 'NI' ||
|
|
||||||
region === 'BB' ||
|
|
||||||
region === 'HB' ||
|
|
||||||
region === 'HH' ||
|
|
||||||
region === 'MV' ||
|
|
||||||
region === 'SN' ||
|
|
||||||
region === 'ST' ||
|
|
||||||
region === 'TH' ||
|
|
||||||
region === 'SH' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
holidays.push(newHoliday('REFORMATIONSTAG', makeDate(year, 10, 31)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addAllerheiligen(year, region, holidays) {
|
|
||||||
if (region === 'BW' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'NW' ||
|
|
||||||
region === 'RP' ||
|
|
||||||
region === 'SL' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
holidays.push(newHoliday('ALLERHEILIGEN', makeDate(year, 11, 1)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addBussUndBetttag(year, region, holidays) {
|
|
||||||
if (region === 'SN' || region === 'ALL') {
|
|
||||||
// @todo write test
|
|
||||||
const bussbettag = getBussBettag(year);
|
|
||||||
holidays.push(newHoliday('BUBETAG', makeDate(bussbettag.getUTCFullYear(), bussbettag.getUTCMonth() + 1, bussbettag.getUTCDate())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addWeltkindertag(year, region, holidays) {
|
|
||||||
if (year >= 2019 && (region === 'TH' || region === 'ALL')) {
|
|
||||||
holidays.push(newHoliday('WELTKINDERTAG', makeDate(year, 9, 20)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addWeltfrauenTag(year, region, feiertageObjects) {
|
|
||||||
if (year <= 2018) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (region === 'BE' || region === 'ALL') {
|
|
||||||
// in Berlin ist der Weltfrauentag ein Feiertag seit 2018
|
|
||||||
feiertageObjects.push(newHoliday('WELTFRAUENTAG', makeDate(year, 3, 8)));
|
|
||||||
}
|
|
||||||
if (region === 'MV' && year >= 2023) {
|
|
||||||
// in MV wird der Weltfrauentag erst ab 2023 eingeführt
|
|
||||||
feiertageObjects.push(newHoliday('WELTFRAUENTAG', makeDate(year, 3, 8)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Calculates the Easter date of a given year.
|
|
||||||
* @param year {number}
|
|
||||||
* @returns {Date} Easter date
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getEasterDate(year) {
|
|
||||||
const C = Math.floor(year / 100);
|
|
||||||
// tslint:disable:binary-expression-operand-order
|
|
||||||
// tslint generates false positives in the following blocks
|
|
||||||
const N = year - 19 * Math.floor(year / 19);
|
|
||||||
const K = Math.floor((C - 17) / 25);
|
|
||||||
let I = C - Math.floor(C / 4) - Math.floor((C - K) / 3) + 19 * N + 15;
|
|
||||||
I -= 30 * Math.floor(I / 30);
|
|
||||||
I -=
|
|
||||||
Math.floor(I / 28) *
|
|
||||||
(1 -
|
|
||||||
Math.floor(I / 28) *
|
|
||||||
Math.floor(29 / (I + 1)) *
|
|
||||||
Math.floor((21 - N) / 11));
|
|
||||||
let J = year + Math.floor(year / 4) + I + 2 - C + Math.floor(C / 4);
|
|
||||||
J -= 7 * Math.floor(J / 7);
|
|
||||||
const L = I - J;
|
|
||||||
const M = 3 + Math.floor((L + 40) / 44);
|
|
||||||
const D = L + 28 - 31 * Math.floor(M / 4);
|
|
||||||
// tslint:enable:binary-expression-operand-order
|
|
||||||
return new Date(year, M - 1, D);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Computes the "Buss- und Bettag"'s date.
|
|
||||||
* @param jahr {number}
|
|
||||||
* @returns {Date} the year's "Buss- und Bettag" date
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getBussBettag(jahr) {
|
|
||||||
const weihnachten = new Date(jahr, 11, 25, 12, 0, 0);
|
|
||||||
const ersterAdventOffset = 32;
|
|
||||||
let wochenTagOffset = weihnachten.getDay() % 7;
|
|
||||||
if (wochenTagOffset === 0) {
|
|
||||||
wochenTagOffset = 7;
|
|
||||||
}
|
|
||||||
const tageVorWeihnachten = wochenTagOffset + ersterAdventOffset;
|
|
||||||
let bbtag = new Date(weihnachten.getTime());
|
|
||||||
bbtag = addDays(bbtag, -tageVorWeihnachten);
|
|
||||||
return bbtag;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Adds {@code days} days to the given {@link Date}.
|
|
||||||
* @param date
|
|
||||||
* @param days
|
|
||||||
* @returns {Date}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function addDays(date, days) {
|
|
||||||
const changedDate = new Date(date);
|
|
||||||
changedDate.setDate(date.getDate() + days);
|
|
||||||
return changedDate;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Creates a new {@link Date}.
|
|
||||||
* @param year
|
|
||||||
* @param naturalMonth month (1-12)
|
|
||||||
* @param day
|
|
||||||
* @returns {Date}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function makeDate(year, naturalMonth, day) {
|
|
||||||
return new Date(year, naturalMonth - 1, day);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @param date
|
|
||||||
* @returns {Holiday}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function newHoliday(name, date) {
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
date,
|
|
||||||
dateString: localeDateObjectToDateString(date),
|
|
||||||
trans(lang = currentLanguage) {
|
|
||||||
console.warn('FeiertageJs: You are using "Holiday.trans() method. This will be replaced in the next major version with translate()"');
|
|
||||||
return this.translate(lang);
|
|
||||||
},
|
|
||||||
translate(lang = currentLanguage) {
|
|
||||||
return lang === undefined || lang === null
|
|
||||||
? undefined
|
|
||||||
: translations[lang][this.name];
|
|
||||||
},
|
|
||||||
getNormalizedDate() {
|
|
||||||
return toUtcTimestamp(this.date);
|
|
||||||
},
|
|
||||||
equals(otherDate) {
|
|
||||||
const dateString = localeDateObjectToDateString(otherDate);
|
|
||||||
return this.dateString === dateString;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param date
|
|
||||||
* @returns {string}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function localeDateObjectToDateString(date) {
|
|
||||||
const normalizedDate = new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000);
|
|
||||||
normalizedDate.setUTCHours(0, 0, 0, 0);
|
|
||||||
return normalizedDate.toISOString().slice(0, 10);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns the UTC timestamp of the given date with hours, minutes, seconds, and milliseconds set to zero.
|
|
||||||
* @param date
|
|
||||||
* @returns {number} UTC timestamp
|
|
||||||
*/
|
|
||||||
function toUtcTimestamp(date) {
|
|
||||||
const internalDate = new Date(date);
|
|
||||||
internalDate.setHours(0, 0, 0, 0);
|
|
||||||
return internalDate.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
export { addTranslation, getHolidayByDate, getHolidays, getLanguage, isHoliday, isSpecificHoliday, isSunOrHoliday, setLanguage };
|
|
||||||
//# sourceMappingURL=feiertage.esm.js.map
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"feiertage.esm.js","sources":["../src/german-translations.ts","../src/holiday-type.ts","../src/regions.ts","../src/feiertage.ts"],"sourcesContent":["import { TranslationTable } from './feiertage';\n\nexport const germanTranslations: TranslationTable = {\n NEUJAHRSTAG: 'Neujahrstag',\n HEILIGEDREIKOENIGE: 'Heilige Drei Könige',\n KARFREITAG: 'Karfreitag',\n OSTERSONNTAG: 'Ostersonntag',\n OSTERMONTAG: 'Ostermontag',\n TAG_DER_ARBEIT: 'Tag der Arbeit',\n CHRISTIHIMMELFAHRT: 'Christi Himmelfahrt',\n PFINGSTSONNTAG: 'Pfingstsonntag',\n PFINGSTMONTAG: 'Pfingstmontag',\n FRONLEICHNAM: 'Fronleichnam',\n MARIAHIMMELFAHRT: 'Mariä Himmelfahrt',\n DEUTSCHEEINHEIT: 'Tag der Deutschen Einheit',\n REFORMATIONSTAG: 'Reformationstag',\n ALLERHEILIGEN: 'Allerheiligen',\n BUBETAG: 'Buß- und Bettag',\n ERSTERWEIHNACHTSFEIERTAG: '1. Weihnachtstag',\n ZWEITERWEIHNACHTSFEIERTAG: '2. Weihnachtstag',\n WELTKINDERTAG: 'Weltkindertag',\n WELTFRAUENTAG: 'Weltfrauentag',\n AUGSBURGER_FRIEDENSFEST: 'Augsburger Friedensfest',\n};\n","export type HolidayType =\n | 'NEUJAHRSTAG'\n | 'HEILIGEDREIKOENIGE'\n | 'KARFREITAG'\n | 'OSTERSONNTAG'\n | 'OSTERMONTAG'\n | 'TAG_DER_ARBEIT'\n | 'CHRISTIHIMMELFAHRT'\n | 'MARIAHIMMELFAHRT'\n | 'PFINGSTSONNTAG'\n | 'PFINGSTMONTAG'\n | 'FRONLEICHNAM'\n | 'DEUTSCHEEINHEIT'\n | 'REFORMATIONSTAG'\n | 'ALLERHEILIGEN'\n | 'BUBETAG'\n | 'ERSTERWEIHNACHTSFEIERTAG'\n | 'ZWEITERWEIHNACHTSFEIERTAG'\n | 'WELTKINDERTAG'\n | 'WELTFRAUENTAG'\n | 'AUGSBURGER_FRIEDENSFEST';\n\nexport const allHolidays: HolidayType[] = [\n 'NEUJAHRSTAG',\n 'HEILIGEDREIKOENIGE',\n 'KARFREITAG',\n 'OSTERSONNTAG',\n 'OSTERMONTAG',\n 'TAG_DER_ARBEIT',\n 'CHRISTIHIMMELFAHRT',\n 'MARIAHIMMELFAHRT',\n 'PFINGSTSONNTAG',\n 'PFINGSTMONTAG',\n 'FRONLEICHNAM',\n 'DEUTSCHEEINHEIT',\n 'REFORMATIONSTAG',\n 'ALLERHEILIGEN',\n 'BUBETAG',\n 'ERSTERWEIHNACHTSFEIERTAG',\n 'ZWEITERWEIHNACHTSFEIERTAG',\n 'WELTKINDERTAG',\n 'WELTFRAUENTAG',\n 'AUGSBURGER_FRIEDENSFEST',\n];\n","export type Region =\n | 'BW' // Baden-Württemberg\n | 'BY' // Bayern\n | 'BE' // Berlin\n | 'BB' // Brandenburg\n | 'HB' // Bremen\n | 'HE' // Hessen\n | 'HH' // Hamburg\n | 'MV' // Mecklenburg-Vorpommern\n | 'NI' // Niedersachsen\n | 'NW' // Nordrhein-Westfalen\n | 'RP' // Rheinland-Pfalz\n | 'SL' // Saarland\n | 'SN' // Sachsen\n | 'ST' // Sachsen-Anhalt\n | 'SH' // Schleswig-Holstein\n | 'TH' // Thüringen\n | 'BUND' // Gesamt-Deutschland\n // Custom regions with local holidays (incompelte) !\n | 'AUGSBURG'\n | 'ALL';\n\nexport const allRegions: Region[] = [\n 'BW',\n 'BY',\n 'BE',\n 'BB',\n 'HB',\n 'HE',\n 'HH',\n 'MV',\n 'NI',\n 'NW',\n 'RP',\n 'SL',\n 'SN',\n 'ST',\n 'SH',\n 'TH',\n 'BUND',\n 'AUGSBURG',\n 'ALL',\n];\n","/*!\n * feiertage.js\n * @repository https://github.com/sfakir/feiertagejs\n * @docs https://github.com/sfakir/feiertagejs/blob/master/docs.md\n *\n * Copyright 2015-2021 Simon Fakir\n * Released under the MIT license\n */\n\n//\n// Additional readings\n// - how to format a javascript date: http://blog.stevenlevithan.com/archives/date-time-format\n// - the right javascript date: http://stackoverflow.com/questions/10286204/the-right-json-date-format\n//\n\nimport { germanTranslations } from './german-translations';\nimport { Holiday } from './holiday';\nimport { allHolidays, HolidayType } from './holiday-type';\nimport { allRegions, Region } from './regions';\n\n// translations\n\nconst defaultLanguage = 'de';\nlet currentLanguage: string = defaultLanguage;\n\n/**\n * Map of {@link HolidayType} to translation string.\n */\nexport type TranslationTable = { [key in HolidayType]?: string };\n\nconst translations: { [key: string]: TranslationTable } = {\n de: germanTranslations,\n};\n\n/**\n * adds a translation for the holidays (e.g. english).\n * This also allows to override the German names.\n * Hint: Interpolates German for missing translations\n * @param {string} isoCode of the new language\n * @param {TranslationTable} newTranslation map of {HolidayType} to translation stringg\n */\nexport function addTranslation(\n isoCode: string,\n newTranslation: TranslationTable,\n): void {\n const code = isoCode.toLowerCase();\n const defaultTranslation = translations[defaultLanguage];\n let missingFields = false;\n\n // fill new Translation with default Language\n for (const holiday of allHolidays) {\n if (!newTranslation[holiday]) {\n missingFields = true;\n newTranslation[holiday] = defaultTranslation[holiday];\n }\n }\n if (missingFields) {\n console.warn(\n '[feiertagejs] addTranslation: you did not add all holidays in your translation! Took German as fallback',\n );\n }\n\n translations[code] = newTranslation;\n}\n\n/**\n * Set a language to default language\n * @param {string} isoCode\n */\nexport function setLanguage(isoCode: string): void {\n const code = isoCode.toLowerCase();\n if (!translations[code])Line truncated
|
|
||||||
-476
@@ -1,476 +0,0 @@
|
|||||||
const germanTranslations = {
|
|
||||||
NEUJAHRSTAG: 'Neujahrstag',
|
|
||||||
HEILIGEDREIKOENIGE: 'Heilige Drei Könige',
|
|
||||||
KARFREITAG: 'Karfreitag',
|
|
||||||
OSTERSONNTAG: 'Ostersonntag',
|
|
||||||
OSTERMONTAG: 'Ostermontag',
|
|
||||||
TAG_DER_ARBEIT: 'Tag der Arbeit',
|
|
||||||
CHRISTIHIMMELFAHRT: 'Christi Himmelfahrt',
|
|
||||||
PFINGSTSONNTAG: 'Pfingstsonntag',
|
|
||||||
PFINGSTMONTAG: 'Pfingstmontag',
|
|
||||||
FRONLEICHNAM: 'Fronleichnam',
|
|
||||||
MARIAHIMMELFAHRT: 'Mariä Himmelfahrt',
|
|
||||||
DEUTSCHEEINHEIT: 'Tag der Deutschen Einheit',
|
|
||||||
REFORMATIONSTAG: 'Reformationstag',
|
|
||||||
ALLERHEILIGEN: 'Allerheiligen',
|
|
||||||
BUBETAG: 'Buß- und Bettag',
|
|
||||||
ERSTERWEIHNACHTSFEIERTAG: '1. Weihnachtstag',
|
|
||||||
ZWEITERWEIHNACHTSFEIERTAG: '2. Weihnachtstag',
|
|
||||||
WELTKINDERTAG: 'Weltkindertag',
|
|
||||||
WELTFRAUENTAG: 'Weltfrauentag',
|
|
||||||
AUGSBURGER_FRIEDENSFEST: 'Augsburger Friedensfest',
|
|
||||||
};
|
|
||||||
|
|
||||||
const allHolidays = [
|
|
||||||
'NEUJAHRSTAG',
|
|
||||||
'HEILIGEDREIKOENIGE',
|
|
||||||
'KARFREITAG',
|
|
||||||
'OSTERSONNTAG',
|
|
||||||
'OSTERMONTAG',
|
|
||||||
'TAG_DER_ARBEIT',
|
|
||||||
'CHRISTIHIMMELFAHRT',
|
|
||||||
'MARIAHIMMELFAHRT',
|
|
||||||
'PFINGSTSONNTAG',
|
|
||||||
'PFINGSTMONTAG',
|
|
||||||
'FRONLEICHNAM',
|
|
||||||
'DEUTSCHEEINHEIT',
|
|
||||||
'REFORMATIONSTAG',
|
|
||||||
'ALLERHEILIGEN',
|
|
||||||
'BUBETAG',
|
|
||||||
'ERSTERWEIHNACHTSFEIERTAG',
|
|
||||||
'ZWEITERWEIHNACHTSFEIERTAG',
|
|
||||||
'WELTKINDERTAG',
|
|
||||||
'WELTFRAUENTAG',
|
|
||||||
'AUGSBURGER_FRIEDENSFEST',
|
|
||||||
];
|
|
||||||
|
|
||||||
const allRegions = [
|
|
||||||
'BW',
|
|
||||||
'BY',
|
|
||||||
'BE',
|
|
||||||
'BB',
|
|
||||||
'HB',
|
|
||||||
'HE',
|
|
||||||
'HH',
|
|
||||||
'MV',
|
|
||||||
'NI',
|
|
||||||
'NW',
|
|
||||||
'RP',
|
|
||||||
'SL',
|
|
||||||
'SN',
|
|
||||||
'ST',
|
|
||||||
'SH',
|
|
||||||
'TH',
|
|
||||||
'BUND',
|
|
||||||
'AUGSBURG',
|
|
||||||
'ALL',
|
|
||||||
];
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* feiertage.js
|
|
||||||
* @repository https://github.com/sfakir/feiertagejs
|
|
||||||
* @docs https://github.com/sfakir/feiertagejs/blob/master/docs.md
|
|
||||||
*
|
|
||||||
* Copyright 2015-2021 Simon Fakir
|
|
||||||
* Released under the MIT license
|
|
||||||
*/
|
|
||||||
// translations
|
|
||||||
const defaultLanguage = 'de';
|
|
||||||
let currentLanguage = defaultLanguage;
|
|
||||||
const translations = {
|
|
||||||
de: germanTranslations,
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* adds a translation for the holidays (e.g. english).
|
|
||||||
* This also allows to override the German names.
|
|
||||||
* Hint: Interpolates German for missing translations
|
|
||||||
* @param {string} isoCode of the new language
|
|
||||||
* @param {TranslationTable} newTranslation map of {HolidayType} to translation stringg
|
|
||||||
*/
|
|
||||||
function addTranslation(isoCode, newTranslation) {
|
|
||||||
const code = isoCode.toLowerCase();
|
|
||||||
const defaultTranslation = translations[defaultLanguage];
|
|
||||||
let missingFields = false;
|
|
||||||
// fill new Translation with default Language
|
|
||||||
for (const holiday of allHolidays) {
|
|
||||||
if (!newTranslation[holiday]) {
|
|
||||||
missingFields = true;
|
|
||||||
newTranslation[holiday] = defaultTranslation[holiday];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (missingFields) {
|
|
||||||
console.warn('[feiertagejs] addTranslation: you did not add all holidays in your translation! Took German as fallback');
|
|
||||||
}
|
|
||||||
translations[code] = newTranslation;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set a language to default language
|
|
||||||
* @param {string} isoCode
|
|
||||||
*/
|
|
||||||
function setLanguage(isoCode) {
|
|
||||||
const code = isoCode.toLowerCase();
|
|
||||||
if (!translations[code]) {
|
|
||||||
throw new TypeError(`[feiertagejs] tried to set language to ${code} but the translation is missing. Please use addTranslation(isoCode,object) first`);
|
|
||||||
}
|
|
||||||
currentLanguage = isoCode;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get currently set language
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
function getLanguage() {
|
|
||||||
return currentLanguage;
|
|
||||||
}
|
|
||||||
// holidays api
|
|
||||||
/**
|
|
||||||
* Checks if a specific date is sunday or holiday.
|
|
||||||
* @param date
|
|
||||||
* @param region
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
function isSunOrHoliday(date, region) {
|
|
||||||
checkRegion(region);
|
|
||||||
return date.getDay() === 0 || isHoliday(date, region);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Check is specific date is holiday.
|
|
||||||
* @param date
|
|
||||||
* @param {Region} region two character {@link Region} code
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
function isHoliday(date, region) {
|
|
||||||
checkRegion(region);
|
|
||||||
const year = date.getFullYear();
|
|
||||||
const internalDate = toUtcTimestamp(date);
|
|
||||||
const holidays = getHolidaysAsUtcTimestamps(year, region);
|
|
||||||
return holidays.indexOf(internalDate) !== -1;
|
|
||||||
}
|
|
||||||
function getHolidayByDate(date, region = 'ALL') {
|
|
||||||
checkRegion(region);
|
|
||||||
const holidays = getHolidaysOfYear(date.getFullYear(), region);
|
|
||||||
return holidays.find((holiday) => holiday.equals(date));
|
|
||||||
}
|
|
||||||
// additional runtime checks
|
|
||||||
/**
|
|
||||||
* Checks if the given region is a valid {@link Region}.
|
|
||||||
*
|
|
||||||
* @param region {@link Region} to check
|
|
||||||
* @throws {Error}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function checkRegion(region) {
|
|
||||||
if (region === null || region === undefined) {
|
|
||||||
throw new Error(`Region must not be undefined or null`);
|
|
||||||
}
|
|
||||||
if (allRegions.indexOf(region) === -1) {
|
|
||||||
throw new Error(`Invalid region: ${region}! Must be one of ${allRegions.toString()}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Checks if the given holidayName is a valid {@link HolidayType}.
|
|
||||||
* @param holidayName {@link HolidayType} to check
|
|
||||||
* @throws {Error}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function checkHolidayType(holidayName) {
|
|
||||||
if (holidayName === null || holidayName === undefined) {
|
|
||||||
throw new TypeError('holidayName must not be null or undefined');
|
|
||||||
}
|
|
||||||
if (allHolidays.indexOf(holidayName) === -1) {
|
|
||||||
throw new Error(`feiertage.js: invalid holiday type "${holidayName}"! Must be one of ${allHolidays.toString()}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function isSpecificHoliday(date, holidayName, region = 'ALL') {
|
|
||||||
checkRegion(region);
|
|
||||||
checkHolidayType(holidayName);
|
|
||||||
const holidays = getHolidaysOfYear(date.getFullYear(), region);
|
|
||||||
const foundHoliday = holidays.find((holiday) => holiday.equals(date));
|
|
||||||
if (!foundHoliday) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return foundHoliday.name === holidayName;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns all holidays of a year in a {@link Region}.
|
|
||||||
* @param year
|
|
||||||
* @param region
|
|
||||||
* @returns {Array.<Holiday>}
|
|
||||||
*/
|
|
||||||
function getHolidays(year, region) {
|
|
||||||
let y;
|
|
||||||
if (typeof year === 'string') {
|
|
||||||
y = parseInt(year, 10);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
y = year;
|
|
||||||
}
|
|
||||||
checkRegion(region);
|
|
||||||
return getHolidaysOfYear(y, region);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {number} year
|
|
||||||
* @param region
|
|
||||||
* @returns {number[]}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getHolidaysAsUtcTimestamps(year, region) {
|
|
||||||
const holidays = getHolidaysOfYear(year, region);
|
|
||||||
return holidays.map((holiday) => toUtcTimestamp(holiday.date));
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {number} year
|
|
||||||
* @param region
|
|
||||||
* @returns {{objects: Array.<Holiday>, integers}}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getHolidaysOfYear(year, region) {
|
|
||||||
const easterDate = getEasterDate(year);
|
|
||||||
const karfreitag = addDays(new Date(easterDate.getTime()), -2);
|
|
||||||
const ostermontag = addDays(new Date(easterDate.getTime()), 1);
|
|
||||||
const christiHimmelfahrt = addDays(new Date(easterDate.getTime()), 39);
|
|
||||||
const pfingstsonntag = addDays(new Date(easterDate.getTime()), 49);
|
|
||||||
const pfingstmontag = addDays(new Date(easterDate.getTime()), 50);
|
|
||||||
const holidays = [
|
|
||||||
...getCommonHolidays(year),
|
|
||||||
newHoliday('KARFREITAG', karfreitag),
|
|
||||||
newHoliday('OSTERMONTAG', ostermontag),
|
|
||||||
newHoliday('CHRISTIHIMMELFAHRT', christiHimmelfahrt),
|
|
||||||
newHoliday('PFINGSTMONTAG', pfingstmontag),
|
|
||||||
];
|
|
||||||
addHeiligeDreiKoenige(year, region, holidays);
|
|
||||||
addEasterAndPfingsten(year, region, easterDate, pfingstsonntag, holidays);
|
|
||||||
addFronleichnam(region, easterDate, holidays);
|
|
||||||
addMariaeHimmelfahrt(year, region, holidays);
|
|
||||||
addReformationstag(year, region, holidays);
|
|
||||||
addAllerheiligen(year, region, holidays);
|
|
||||||
addBussUndBetttag(year, region, holidays);
|
|
||||||
addWeltkindertag(year, region, holidays);
|
|
||||||
addWeltfrauenTag(year, region, holidays);
|
|
||||||
addRegionalHolidays(year, region, holidays);
|
|
||||||
return holidays.sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
||||||
}
|
|
||||||
function getCommonHolidays(year) {
|
|
||||||
return [
|
|
||||||
newHoliday('NEUJAHRSTAG', makeDate(year, 1, 1)),
|
|
||||||
newHoliday('TAG_DER_ARBEIT', makeDate(year, 5, 1)),
|
|
||||||
newHoliday('DEUTSCHEEINHEIT', makeDate(year, 10, 3)),
|
|
||||||
newHoliday('ERSTERWEIHNACHTSFEIERTAG', makeDate(year, 12, 25)),
|
|
||||||
newHoliday('ZWEITERWEIHNACHTSFEIERTAG', makeDate(year, 12, 26)),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
function addRegionalHolidays(year, region, feiertageObjects) {
|
|
||||||
if (region === 'AUGSBURG') {
|
|
||||||
feiertageObjects.push(newHoliday('AUGSBURGER_FRIEDENSFEST', makeDate(year, 8, 8)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addHeiligeDreiKoenige(year, region, feiertageObjects) {
|
|
||||||
if (region === 'BW' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'ST' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
feiertageObjects.push(newHoliday('HEILIGEDREIKOENIGE', makeDate(year, 1, 6)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addEasterAndPfingsten(year, region, easterDate, pfingstsonntag, feiertageObjects) {
|
|
||||||
if (region === 'BB' || region === 'ALL') {
|
|
||||||
feiertageObjects.push(newHoliday('OSTERSONNTAG', easterDate), newHoliday('PFINGSTSONNTAG', pfingstsonntag));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addFronleichnam(region, easterDate, holidays) {
|
|
||||||
if (region === 'BW' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'HE' ||
|
|
||||||
region === 'NW' ||
|
|
||||||
region === 'RP' ||
|
|
||||||
region === 'SL' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
const fronleichnam = addDays(new Date(easterDate.getTime()), 60);
|
|
||||||
holidays.push(newHoliday('FRONLEICHNAM', fronleichnam));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addMariaeHimmelfahrt(year, region, holidays) {
|
|
||||||
if (region === 'SL' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
holidays.push(newHoliday('MARIAHIMMELFAHRT', makeDate(year, 8, 15)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addReformationstag(year, region, holidays) {
|
|
||||||
if (year === 2017 ||
|
|
||||||
region === 'NI' ||
|
|
||||||
region === 'BB' ||
|
|
||||||
region === 'HB' ||
|
|
||||||
region === 'HH' ||
|
|
||||||
region === 'MV' ||
|
|
||||||
region === 'SN' ||
|
|
||||||
region === 'ST' ||
|
|
||||||
region === 'TH' ||
|
|
||||||
region === 'SH' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
holidays.push(newHoliday('REFORMATIONSTAG', makeDate(year, 10, 31)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addAllerheiligen(year, region, holidays) {
|
|
||||||
if (region === 'BW' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'NW' ||
|
|
||||||
region === 'RP' ||
|
|
||||||
region === 'SL' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
holidays.push(newHoliday('ALLERHEILIGEN', makeDate(year, 11, 1)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addBussUndBetttag(year, region, holidays) {
|
|
||||||
if (region === 'SN' || region === 'ALL') {
|
|
||||||
// @todo write test
|
|
||||||
const bussbettag = getBussBettag(year);
|
|
||||||
holidays.push(newHoliday('BUBETAG', makeDate(bussbettag.getUTCFullYear(), bussbettag.getUTCMonth() + 1, bussbettag.getUTCDate())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addWeltkindertag(year, region, holidays) {
|
|
||||||
if (year >= 2019 && (region === 'TH' || region === 'ALL')) {
|
|
||||||
holidays.push(newHoliday('WELTKINDERTAG', makeDate(year, 9, 20)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addWeltfrauenTag(year, region, feiertageObjects) {
|
|
||||||
if (year <= 2018) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (region === 'BE' || region === 'ALL') {
|
|
||||||
// in Berlin ist der Weltfrauentag ein Feiertag seit 2018
|
|
||||||
feiertageObjects.push(newHoliday('WELTFRAUENTAG', makeDate(year, 3, 8)));
|
|
||||||
}
|
|
||||||
if (region === 'MV' && year >= 2023) {
|
|
||||||
// in MV wird der Weltfrauentag erst ab 2023 eingeführt
|
|
||||||
feiertageObjects.push(newHoliday('WELTFRAUENTAG', makeDate(year, 3, 8)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Calculates the Easter date of a given year.
|
|
||||||
* @param year {number}
|
|
||||||
* @returns {Date} Easter date
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getEasterDate(year) {
|
|
||||||
const C = Math.floor(year / 100);
|
|
||||||
// tslint:disable:binary-expression-operand-order
|
|
||||||
// tslint generates false positives in the following blocks
|
|
||||||
const N = year - 19 * Math.floor(year / 19);
|
|
||||||
const K = Math.floor((C - 17) / 25);
|
|
||||||
let I = C - Math.floor(C / 4) - Math.floor((C - K) / 3) + 19 * N + 15;
|
|
||||||
I -= 30 * Math.floor(I / 30);
|
|
||||||
I -=
|
|
||||||
Math.floor(I / 28) *
|
|
||||||
(1 -
|
|
||||||
Math.floor(I / 28) *
|
|
||||||
Math.floor(29 / (I + 1)) *
|
|
||||||
Math.floor((21 - N) / 11));
|
|
||||||
let J = year + Math.floor(year / 4) + I + 2 - C + Math.floor(C / 4);
|
|
||||||
J -= 7 * Math.floor(J / 7);
|
|
||||||
const L = I - J;
|
|
||||||
const M = 3 + Math.floor((L + 40) / 44);
|
|
||||||
const D = L + 28 - 31 * Math.floor(M / 4);
|
|
||||||
// tslint:enable:binary-expression-operand-order
|
|
||||||
return new Date(year, M - 1, D);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Computes the "Buss- und Bettag"'s date.
|
|
||||||
* @param jahr {number}
|
|
||||||
* @returns {Date} the year's "Buss- und Bettag" date
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getBussBettag(jahr) {
|
|
||||||
const weihnachten = new Date(jahr, 11, 25, 12, 0, 0);
|
|
||||||
const ersterAdventOffset = 32;
|
|
||||||
let wochenTagOffset = weihnachten.getDay() % 7;
|
|
||||||
if (wochenTagOffset === 0) {
|
|
||||||
wochenTagOffset = 7;
|
|
||||||
}
|
|
||||||
const tageVorWeihnachten = wochenTagOffset + ersterAdventOffset;
|
|
||||||
let bbtag = new Date(weihnachten.getTime());
|
|
||||||
bbtag = addDays(bbtag, -tageVorWeihnachten);
|
|
||||||
return bbtag;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Adds {@code days} days to the given {@link Date}.
|
|
||||||
* @param date
|
|
||||||
* @param days
|
|
||||||
* @returns {Date}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function addDays(date, days) {
|
|
||||||
const changedDate = new Date(date);
|
|
||||||
changedDate.setDate(date.getDate() + days);
|
|
||||||
return changedDate;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Creates a new {@link Date}.
|
|
||||||
* @param year
|
|
||||||
* @param naturalMonth month (1-12)
|
|
||||||
* @param day
|
|
||||||
* @returns {Date}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function makeDate(year, naturalMonth, day) {
|
|
||||||
return new Date(year, naturalMonth - 1, day);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @param date
|
|
||||||
* @returns {Holiday}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function newHoliday(name, date) {
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
date,
|
|
||||||
dateString: localeDateObjectToDateString(date),
|
|
||||||
trans(lang = currentLanguage) {
|
|
||||||
console.warn('FeiertageJs: You are using "Holiday.trans() method. This will be replaced in the next major version with translate()"');
|
|
||||||
return this.translate(lang);
|
|
||||||
},
|
|
||||||
translate(lang = currentLanguage) {
|
|
||||||
return lang === undefined || lang === null
|
|
||||||
? undefined
|
|
||||||
: translations[lang][this.name];
|
|
||||||
},
|
|
||||||
getNormalizedDate() {
|
|
||||||
return toUtcTimestamp(this.date);
|
|
||||||
},
|
|
||||||
equals(otherDate) {
|
|
||||||
const dateString = localeDateObjectToDateString(otherDate);
|
|
||||||
return this.dateString === dateString;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param date
|
|
||||||
* @returns {string}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function localeDateObjectToDateString(date) {
|
|
||||||
const normalizedDate = new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000);
|
|
||||||
normalizedDate.setUTCHours(0, 0, 0, 0);
|
|
||||||
return normalizedDate.toISOString().slice(0, 10);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns the UTC timestamp of the given date with hours, minutes, seconds, and milliseconds set to zero.
|
|
||||||
* @param date
|
|
||||||
* @returns {number} UTC timestamp
|
|
||||||
*/
|
|
||||||
function toUtcTimestamp(date) {
|
|
||||||
const internalDate = new Date(date);
|
|
||||||
internalDate.setHours(0, 0, 0, 0);
|
|
||||||
return internalDate.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
export { addTranslation, getHolidayByDate, getHolidays, getLanguage, isHoliday, isSpecificHoliday, isSunOrHoliday, setLanguage };
|
|
||||||
//# sourceMappingURL=feiertage.js.map
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"feiertage.js","sources":["../src/german-translations.ts","../src/holiday-type.ts","../src/regions.ts","../src/feiertage.ts"],"sourcesContent":["import { TranslationTable } from './feiertage';\n\nexport const germanTranslations: TranslationTable = {\n NEUJAHRSTAG: 'Neujahrstag',\n HEILIGEDREIKOENIGE: 'Heilige Drei Könige',\n KARFREITAG: 'Karfreitag',\n OSTERSONNTAG: 'Ostersonntag',\n OSTERMONTAG: 'Ostermontag',\n TAG_DER_ARBEIT: 'Tag der Arbeit',\n CHRISTIHIMMELFAHRT: 'Christi Himmelfahrt',\n PFINGSTSONNTAG: 'Pfingstsonntag',\n PFINGSTMONTAG: 'Pfingstmontag',\n FRONLEICHNAM: 'Fronleichnam',\n MARIAHIMMELFAHRT: 'Mariä Himmelfahrt',\n DEUTSCHEEINHEIT: 'Tag der Deutschen Einheit',\n REFORMATIONSTAG: 'Reformationstag',\n ALLERHEILIGEN: 'Allerheiligen',\n BUBETAG: 'Buß- und Bettag',\n ERSTERWEIHNACHTSFEIERTAG: '1. Weihnachtstag',\n ZWEITERWEIHNACHTSFEIERTAG: '2. Weihnachtstag',\n WELTKINDERTAG: 'Weltkindertag',\n WELTFRAUENTAG: 'Weltfrauentag',\n AUGSBURGER_FRIEDENSFEST: 'Augsburger Friedensfest',\n};\n","export type HolidayType =\n | 'NEUJAHRSTAG'\n | 'HEILIGEDREIKOENIGE'\n | 'KARFREITAG'\n | 'OSTERSONNTAG'\n | 'OSTERMONTAG'\n | 'TAG_DER_ARBEIT'\n | 'CHRISTIHIMMELFAHRT'\n | 'MARIAHIMMELFAHRT'\n | 'PFINGSTSONNTAG'\n | 'PFINGSTMONTAG'\n | 'FRONLEICHNAM'\n | 'DEUTSCHEEINHEIT'\n | 'REFORMATIONSTAG'\n | 'ALLERHEILIGEN'\n | 'BUBETAG'\n | 'ERSTERWEIHNACHTSFEIERTAG'\n | 'ZWEITERWEIHNACHTSFEIERTAG'\n | 'WELTKINDERTAG'\n | 'WELTFRAUENTAG'\n | 'AUGSBURGER_FRIEDENSFEST';\n\nexport const allHolidays: HolidayType[] = [\n 'NEUJAHRSTAG',\n 'HEILIGEDREIKOENIGE',\n 'KARFREITAG',\n 'OSTERSONNTAG',\n 'OSTERMONTAG',\n 'TAG_DER_ARBEIT',\n 'CHRISTIHIMMELFAHRT',\n 'MARIAHIMMELFAHRT',\n 'PFINGSTSONNTAG',\n 'PFINGSTMONTAG',\n 'FRONLEICHNAM',\n 'DEUTSCHEEINHEIT',\n 'REFORMATIONSTAG',\n 'ALLERHEILIGEN',\n 'BUBETAG',\n 'ERSTERWEIHNACHTSFEIERTAG',\n 'ZWEITERWEIHNACHTSFEIERTAG',\n 'WELTKINDERTAG',\n 'WELTFRAUENTAG',\n 'AUGSBURGER_FRIEDENSFEST',\n];\n","export type Region =\n | 'BW' // Baden-Württemberg\n | 'BY' // Bayern\n | 'BE' // Berlin\n | 'BB' // Brandenburg\n | 'HB' // Bremen\n | 'HE' // Hessen\n | 'HH' // Hamburg\n | 'MV' // Mecklenburg-Vorpommern\n | 'NI' // Niedersachsen\n | 'NW' // Nordrhein-Westfalen\n | 'RP' // Rheinland-Pfalz\n | 'SL' // Saarland\n | 'SN' // Sachsen\n | 'ST' // Sachsen-Anhalt\n | 'SH' // Schleswig-Holstein\n | 'TH' // Thüringen\n | 'BUND' // Gesamt-Deutschland\n // Custom regions with local holidays (incompelte) !\n | 'AUGSBURG'\n | 'ALL';\n\nexport const allRegions: Region[] = [\n 'BW',\n 'BY',\n 'BE',\n 'BB',\n 'HB',\n 'HE',\n 'HH',\n 'MV',\n 'NI',\n 'NW',\n 'RP',\n 'SL',\n 'SN',\n 'ST',\n 'SH',\n 'TH',\n 'BUND',\n 'AUGSBURG',\n 'ALL',\n];\n","/*!\n * feiertage.js\n * @repository https://github.com/sfakir/feiertagejs\n * @docs https://github.com/sfakir/feiertagejs/blob/master/docs.md\n *\n * Copyright 2015-2021 Simon Fakir\n * Released under the MIT license\n */\n\n//\n// Additional readings\n// - how to format a javascript date: http://blog.stevenlevithan.com/archives/date-time-format\n// - the right javascript date: http://stackoverflow.com/questions/10286204/the-right-json-date-format\n//\n\nimport { germanTranslations } from './german-translations';\nimport { Holiday } from './holiday';\nimport { allHolidays, HolidayType } from './holiday-type';\nimport { allRegions, Region } from './regions';\n\n// translations\n\nconst defaultLanguage = 'de';\nlet currentLanguage: string = defaultLanguage;\n\n/**\n * Map of {@link HolidayType} to translation string.\n */\nexport type TranslationTable = { [key in HolidayType]?: string };\n\nconst translations: { [key: string]: TranslationTable } = {\n de: germanTranslations,\n};\n\n/**\n * adds a translation for the holidays (e.g. english).\n * This also allows to override the German names.\n * Hint: Interpolates German for missing translations\n * @param {string} isoCode of the new language\n * @param {TranslationTable} newTranslation map of {HolidayType} to translation stringg\n */\nexport function addTranslation(\n isoCode: string,\n newTranslation: TranslationTable,\n): void {\n const code = isoCode.toLowerCase();\n const defaultTranslation = translations[defaultLanguage];\n let missingFields = false;\n\n // fill new Translation with default Language\n for (const holiday of allHolidays) {\n if (!newTranslation[holiday]) {\n missingFields = true;\n newTranslation[holiday] = defaultTranslation[holiday];\n }\n }\n if (missingFields) {\n console.warn(\n '[feiertagejs] addTranslation: you did not add all holidays in your translation! Took German as fallback',\n );\n }\n\n translations[code] = newTranslation;\n}\n\n/**\n * Set a language to default language\n * @param {string} isoCode\n */\nexport function setLanguage(isoCode: string): void {\n const code = isoCode.toLowerCase();\n if (!translations[code]) {\nLine truncated
|
|
||||||
-496
@@ -1,496 +0,0 @@
|
|||||||
(function (global, factory) {
|
|
||||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
||||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
||||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () {
|
|
||||||
var current = global.feiertagejs;
|
|
||||||
var exports = global.feiertagejs = {};
|
|
||||||
factory(exports);
|
|
||||||
exports.noConflict = function () { global.feiertagejs = current; return exports; };
|
|
||||||
})());
|
|
||||||
})(this, (function (exports) { 'use strict';
|
|
||||||
|
|
||||||
const germanTranslations = {
|
|
||||||
NEUJAHRSTAG: 'Neujahrstag',
|
|
||||||
HEILIGEDREIKOENIGE: 'Heilige Drei Könige',
|
|
||||||
KARFREITAG: 'Karfreitag',
|
|
||||||
OSTERSONNTAG: 'Ostersonntag',
|
|
||||||
OSTERMONTAG: 'Ostermontag',
|
|
||||||
TAG_DER_ARBEIT: 'Tag der Arbeit',
|
|
||||||
CHRISTIHIMMELFAHRT: 'Christi Himmelfahrt',
|
|
||||||
PFINGSTSONNTAG: 'Pfingstsonntag',
|
|
||||||
PFINGSTMONTAG: 'Pfingstmontag',
|
|
||||||
FRONLEICHNAM: 'Fronleichnam',
|
|
||||||
MARIAHIMMELFAHRT: 'Mariä Himmelfahrt',
|
|
||||||
DEUTSCHEEINHEIT: 'Tag der Deutschen Einheit',
|
|
||||||
REFORMATIONSTAG: 'Reformationstag',
|
|
||||||
ALLERHEILIGEN: 'Allerheiligen',
|
|
||||||
BUBETAG: 'Buß- und Bettag',
|
|
||||||
ERSTERWEIHNACHTSFEIERTAG: '1. Weihnachtstag',
|
|
||||||
ZWEITERWEIHNACHTSFEIERTAG: '2. Weihnachtstag',
|
|
||||||
WELTKINDERTAG: 'Weltkindertag',
|
|
||||||
WELTFRAUENTAG: 'Weltfrauentag',
|
|
||||||
AUGSBURGER_FRIEDENSFEST: 'Augsburger Friedensfest',
|
|
||||||
};
|
|
||||||
|
|
||||||
const allHolidays = [
|
|
||||||
'NEUJAHRSTAG',
|
|
||||||
'HEILIGEDREIKOENIGE',
|
|
||||||
'KARFREITAG',
|
|
||||||
'OSTERSONNTAG',
|
|
||||||
'OSTERMONTAG',
|
|
||||||
'TAG_DER_ARBEIT',
|
|
||||||
'CHRISTIHIMMELFAHRT',
|
|
||||||
'MARIAHIMMELFAHRT',
|
|
||||||
'PFINGSTSONNTAG',
|
|
||||||
'PFINGSTMONTAG',
|
|
||||||
'FRONLEICHNAM',
|
|
||||||
'DEUTSCHEEINHEIT',
|
|
||||||
'REFORMATIONSTAG',
|
|
||||||
'ALLERHEILIGEN',
|
|
||||||
'BUBETAG',
|
|
||||||
'ERSTERWEIHNACHTSFEIERTAG',
|
|
||||||
'ZWEITERWEIHNACHTSFEIERTAG',
|
|
||||||
'WELTKINDERTAG',
|
|
||||||
'WELTFRAUENTAG',
|
|
||||||
'AUGSBURGER_FRIEDENSFEST',
|
|
||||||
];
|
|
||||||
|
|
||||||
const allRegions = [
|
|
||||||
'BW',
|
|
||||||
'BY',
|
|
||||||
'BE',
|
|
||||||
'BB',
|
|
||||||
'HB',
|
|
||||||
'HE',
|
|
||||||
'HH',
|
|
||||||
'MV',
|
|
||||||
'NI',
|
|
||||||
'NW',
|
|
||||||
'RP',
|
|
||||||
'SL',
|
|
||||||
'SN',
|
|
||||||
'ST',
|
|
||||||
'SH',
|
|
||||||
'TH',
|
|
||||||
'BUND',
|
|
||||||
'AUGSBURG',
|
|
||||||
'ALL',
|
|
||||||
];
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* feiertage.js
|
|
||||||
* @repository https://github.com/sfakir/feiertagejs
|
|
||||||
* @docs https://github.com/sfakir/feiertagejs/blob/master/docs.md
|
|
||||||
*
|
|
||||||
* Copyright 2015-2021 Simon Fakir
|
|
||||||
* Released under the MIT license
|
|
||||||
*/
|
|
||||||
// translations
|
|
||||||
const defaultLanguage = 'de';
|
|
||||||
let currentLanguage = defaultLanguage;
|
|
||||||
const translations = {
|
|
||||||
de: germanTranslations,
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* adds a translation for the holidays (e.g. english).
|
|
||||||
* This also allows to override the German names.
|
|
||||||
* Hint: Interpolates German for missing translations
|
|
||||||
* @param {string} isoCode of the new language
|
|
||||||
* @param {TranslationTable} newTranslation map of {HolidayType} to translation stringg
|
|
||||||
*/
|
|
||||||
function addTranslation(isoCode, newTranslation) {
|
|
||||||
const code = isoCode.toLowerCase();
|
|
||||||
const defaultTranslation = translations[defaultLanguage];
|
|
||||||
let missingFields = false;
|
|
||||||
// fill new Translation with default Language
|
|
||||||
for (const holiday of allHolidays) {
|
|
||||||
if (!newTranslation[holiday]) {
|
|
||||||
missingFields = true;
|
|
||||||
newTranslation[holiday] = defaultTranslation[holiday];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (missingFields) {
|
|
||||||
console.warn('[feiertagejs] addTranslation: you did not add all holidays in your translation! Took German as fallback');
|
|
||||||
}
|
|
||||||
translations[code] = newTranslation;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set a language to default language
|
|
||||||
* @param {string} isoCode
|
|
||||||
*/
|
|
||||||
function setLanguage(isoCode) {
|
|
||||||
const code = isoCode.toLowerCase();
|
|
||||||
if (!translations[code]) {
|
|
||||||
throw new TypeError(`[feiertagejs] tried to set language to ${code} but the translation is missing. Please use addTranslation(isoCode,object) first`);
|
|
||||||
}
|
|
||||||
currentLanguage = isoCode;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get currently set language
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
function getLanguage() {
|
|
||||||
return currentLanguage;
|
|
||||||
}
|
|
||||||
// holidays api
|
|
||||||
/**
|
|
||||||
* Checks if a specific date is sunday or holiday.
|
|
||||||
* @param date
|
|
||||||
* @param region
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
function isSunOrHoliday(date, region) {
|
|
||||||
checkRegion(region);
|
|
||||||
return date.getDay() === 0 || isHoliday(date, region);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Check is specific date is holiday.
|
|
||||||
* @param date
|
|
||||||
* @param {Region} region two character {@link Region} code
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
function isHoliday(date, region) {
|
|
||||||
checkRegion(region);
|
|
||||||
const year = date.getFullYear();
|
|
||||||
const internalDate = toUtcTimestamp(date);
|
|
||||||
const holidays = getHolidaysAsUtcTimestamps(year, region);
|
|
||||||
return holidays.indexOf(internalDate) !== -1;
|
|
||||||
}
|
|
||||||
function getHolidayByDate(date, region = 'ALL') {
|
|
||||||
checkRegion(region);
|
|
||||||
const holidays = getHolidaysOfYear(date.getFullYear(), region);
|
|
||||||
return holidays.find((holiday) => holiday.equals(date));
|
|
||||||
}
|
|
||||||
// additional runtime checks
|
|
||||||
/**
|
|
||||||
* Checks if the given region is a valid {@link Region}.
|
|
||||||
*
|
|
||||||
* @param region {@link Region} to check
|
|
||||||
* @throws {Error}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function checkRegion(region) {
|
|
||||||
if (region === null || region === undefined) {
|
|
||||||
throw new Error(`Region must not be undefined or null`);
|
|
||||||
}
|
|
||||||
if (allRegions.indexOf(region) === -1) {
|
|
||||||
throw new Error(`Invalid region: ${region}! Must be one of ${allRegions.toString()}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Checks if the given holidayName is a valid {@link HolidayType}.
|
|
||||||
* @param holidayName {@link HolidayType} to check
|
|
||||||
* @throws {Error}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function checkHolidayType(holidayName) {
|
|
||||||
if (holidayName === null || holidayName === undefined) {
|
|
||||||
throw new TypeError('holidayName must not be null or undefined');
|
|
||||||
}
|
|
||||||
if (allHolidays.indexOf(holidayName) === -1) {
|
|
||||||
throw new Error(`feiertage.js: invalid holiday type "${holidayName}"! Must be one of ${allHolidays.toString()}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function isSpecificHoliday(date, holidayName, region = 'ALL') {
|
|
||||||
checkRegion(region);
|
|
||||||
checkHolidayType(holidayName);
|
|
||||||
const holidays = getHolidaysOfYear(date.getFullYear(), region);
|
|
||||||
const foundHoliday = holidays.find((holiday) => holiday.equals(date));
|
|
||||||
if (!foundHoliday) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return foundHoliday.name === holidayName;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns all holidays of a year in a {@link Region}.
|
|
||||||
* @param year
|
|
||||||
* @param region
|
|
||||||
* @returns {Array.<Holiday>}
|
|
||||||
*/
|
|
||||||
function getHolidays(year, region) {
|
|
||||||
let y;
|
|
||||||
if (typeof year === 'string') {
|
|
||||||
y = parseInt(year, 10);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
y = year;
|
|
||||||
}
|
|
||||||
checkRegion(region);
|
|
||||||
return getHolidaysOfYear(y, region);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {number} year
|
|
||||||
* @param region
|
|
||||||
* @returns {number[]}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getHolidaysAsUtcTimestamps(year, region) {
|
|
||||||
const holidays = getHolidaysOfYear(year, region);
|
|
||||||
return holidays.map((holiday) => toUtcTimestamp(holiday.date));
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {number} year
|
|
||||||
* @param region
|
|
||||||
* @returns {{objects: Array.<Holiday>, integers}}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getHolidaysOfYear(year, region) {
|
|
||||||
const easterDate = getEasterDate(year);
|
|
||||||
const karfreitag = addDays(new Date(easterDate.getTime()), -2);
|
|
||||||
const ostermontag = addDays(new Date(easterDate.getTime()), 1);
|
|
||||||
const christiHimmelfahrt = addDays(new Date(easterDate.getTime()), 39);
|
|
||||||
const pfingstsonntag = addDays(new Date(easterDate.getTime()), 49);
|
|
||||||
const pfingstmontag = addDays(new Date(easterDate.getTime()), 50);
|
|
||||||
const holidays = [
|
|
||||||
...getCommonHolidays(year),
|
|
||||||
newHoliday('KARFREITAG', karfreitag),
|
|
||||||
newHoliday('OSTERMONTAG', ostermontag),
|
|
||||||
newHoliday('CHRISTIHIMMELFAHRT', christiHimmelfahrt),
|
|
||||||
newHoliday('PFINGSTMONTAG', pfingstmontag),
|
|
||||||
];
|
|
||||||
addHeiligeDreiKoenige(year, region, holidays);
|
|
||||||
addEasterAndPfingsten(year, region, easterDate, pfingstsonntag, holidays);
|
|
||||||
addFronleichnam(region, easterDate, holidays);
|
|
||||||
addMariaeHimmelfahrt(year, region, holidays);
|
|
||||||
addReformationstag(year, region, holidays);
|
|
||||||
addAllerheiligen(year, region, holidays);
|
|
||||||
addBussUndBetttag(year, region, holidays);
|
|
||||||
addWeltkindertag(year, region, holidays);
|
|
||||||
addWeltfrauenTag(year, region, holidays);
|
|
||||||
addRegionalHolidays(year, region, holidays);
|
|
||||||
return holidays.sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
||||||
}
|
|
||||||
function getCommonHolidays(year) {
|
|
||||||
return [
|
|
||||||
newHoliday('NEUJAHRSTAG', makeDate(year, 1, 1)),
|
|
||||||
newHoliday('TAG_DER_ARBEIT', makeDate(year, 5, 1)),
|
|
||||||
newHoliday('DEUTSCHEEINHEIT', makeDate(year, 10, 3)),
|
|
||||||
newHoliday('ERSTERWEIHNACHTSFEIERTAG', makeDate(year, 12, 25)),
|
|
||||||
newHoliday('ZWEITERWEIHNACHTSFEIERTAG', makeDate(year, 12, 26)),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
function addRegionalHolidays(year, region, feiertageObjects) {
|
|
||||||
if (region === 'AUGSBURG') {
|
|
||||||
feiertageObjects.push(newHoliday('AUGSBURGER_FRIEDENSFEST', makeDate(year, 8, 8)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addHeiligeDreiKoenige(year, region, feiertageObjects) {
|
|
||||||
if (region === 'BW' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'ST' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
feiertageObjects.push(newHoliday('HEILIGEDREIKOENIGE', makeDate(year, 1, 6)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addEasterAndPfingsten(year, region, easterDate, pfingstsonntag, feiertageObjects) {
|
|
||||||
if (region === 'BB' || region === 'ALL') {
|
|
||||||
feiertageObjects.push(newHoliday('OSTERSONNTAG', easterDate), newHoliday('PFINGSTSONNTAG', pfingstsonntag));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addFronleichnam(region, easterDate, holidays) {
|
|
||||||
if (region === 'BW' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'HE' ||
|
|
||||||
region === 'NW' ||
|
|
||||||
region === 'RP' ||
|
|
||||||
region === 'SL' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
const fronleichnam = addDays(new Date(easterDate.getTime()), 60);
|
|
||||||
holidays.push(newHoliday('FRONLEICHNAM', fronleichnam));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addMariaeHimmelfahrt(year, region, holidays) {
|
|
||||||
if (region === 'SL' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
holidays.push(newHoliday('MARIAHIMMELFAHRT', makeDate(year, 8, 15)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addReformationstag(year, region, holidays) {
|
|
||||||
if (year === 2017 ||
|
|
||||||
region === 'NI' ||
|
|
||||||
region === 'BB' ||
|
|
||||||
region === 'HB' ||
|
|
||||||
region === 'HH' ||
|
|
||||||
region === 'MV' ||
|
|
||||||
region === 'SN' ||
|
|
||||||
region === 'ST' ||
|
|
||||||
region === 'TH' ||
|
|
||||||
region === 'SH' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
holidays.push(newHoliday('REFORMATIONSTAG', makeDate(year, 10, 31)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addAllerheiligen(year, region, holidays) {
|
|
||||||
if (region === 'BW' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'NW' ||
|
|
||||||
region === 'RP' ||
|
|
||||||
region === 'SL' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
holidays.push(newHoliday('ALLERHEILIGEN', makeDate(year, 11, 1)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addBussUndBetttag(year, region, holidays) {
|
|
||||||
if (region === 'SN' || region === 'ALL') {
|
|
||||||
// @todo write test
|
|
||||||
const bussbettag = getBussBettag(year);
|
|
||||||
holidays.push(newHoliday('BUBETAG', makeDate(bussbettag.getUTCFullYear(), bussbettag.getUTCMonth() + 1, bussbettag.getUTCDate())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addWeltkindertag(year, region, holidays) {
|
|
||||||
if (year >= 2019 && (region === 'TH' || region === 'ALL')) {
|
|
||||||
holidays.push(newHoliday('WELTKINDERTAG', makeDate(year, 9, 20)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addWeltfrauenTag(year, region, feiertageObjects) {
|
|
||||||
if (year <= 2018) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (region === 'BE' || region === 'ALL') {
|
|
||||||
// in Berlin ist der Weltfrauentag ein Feiertag seit 2018
|
|
||||||
feiertageObjects.push(newHoliday('WELTFRAUENTAG', makeDate(year, 3, 8)));
|
|
||||||
}
|
|
||||||
if (region === 'MV' && year >= 2023) {
|
|
||||||
// in MV wird der Weltfrauentag erst ab 2023 eingeführt
|
|
||||||
feiertageObjects.push(newHoliday('WELTFRAUENTAG', makeDate(year, 3, 8)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Calculates the Easter date of a given year.
|
|
||||||
* @param year {number}
|
|
||||||
* @returns {Date} Easter date
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getEasterDate(year) {
|
|
||||||
const C = Math.floor(year / 100);
|
|
||||||
// tslint:disable:binary-expression-operand-order
|
|
||||||
// tslint generates false positives in the following blocks
|
|
||||||
const N = year - 19 * Math.floor(year / 19);
|
|
||||||
const K = Math.floor((C - 17) / 25);
|
|
||||||
let I = C - Math.floor(C / 4) - Math.floor((C - K) / 3) + 19 * N + 15;
|
|
||||||
I -= 30 * Math.floor(I / 30);
|
|
||||||
I -=
|
|
||||||
Math.floor(I / 28) *
|
|
||||||
(1 -
|
|
||||||
Math.floor(I / 28) *
|
|
||||||
Math.floor(29 / (I + 1)) *
|
|
||||||
Math.floor((21 - N) / 11));
|
|
||||||
let J = year + Math.floor(year / 4) + I + 2 - C + Math.floor(C / 4);
|
|
||||||
J -= 7 * Math.floor(J / 7);
|
|
||||||
const L = I - J;
|
|
||||||
const M = 3 + Math.floor((L + 40) / 44);
|
|
||||||
const D = L + 28 - 31 * Math.floor(M / 4);
|
|
||||||
// tslint:enable:binary-expression-operand-order
|
|
||||||
return new Date(year, M - 1, D);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Computes the "Buss- und Bettag"'s date.
|
|
||||||
* @param jahr {number}
|
|
||||||
* @returns {Date} the year's "Buss- und Bettag" date
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getBussBettag(jahr) {
|
|
||||||
const weihnachten = new Date(jahr, 11, 25, 12, 0, 0);
|
|
||||||
const ersterAdventOffset = 32;
|
|
||||||
let wochenTagOffset = weihnachten.getDay() % 7;
|
|
||||||
if (wochenTagOffset === 0) {
|
|
||||||
wochenTagOffset = 7;
|
|
||||||
}
|
|
||||||
const tageVorWeihnachten = wochenTagOffset + ersterAdventOffset;
|
|
||||||
let bbtag = new Date(weihnachten.getTime());
|
|
||||||
bbtag = addDays(bbtag, -tageVorWeihnachten);
|
|
||||||
return bbtag;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Adds {@code days} days to the given {@link Date}.
|
|
||||||
* @param date
|
|
||||||
* @param days
|
|
||||||
* @returns {Date}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function addDays(date, days) {
|
|
||||||
const changedDate = new Date(date);
|
|
||||||
changedDate.setDate(date.getDate() + days);
|
|
||||||
return changedDate;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Creates a new {@link Date}.
|
|
||||||
* @param year
|
|
||||||
* @param naturalMonth month (1-12)
|
|
||||||
* @param day
|
|
||||||
* @returns {Date}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function makeDate(year, naturalMonth, day) {
|
|
||||||
return new Date(year, naturalMonth - 1, day);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @param date
|
|
||||||
* @returns {Holiday}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function newHoliday(name, date) {
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
date,
|
|
||||||
dateString: localeDateObjectToDateString(date),
|
|
||||||
trans(lang = currentLanguage) {
|
|
||||||
console.warn('FeiertageJs: You are using "Holiday.trans() method. This will be replaced in the next major version with translate()"');
|
|
||||||
return this.translate(lang);
|
|
||||||
},
|
|
||||||
translate(lang = currentLanguage) {
|
|
||||||
return lang === undefined || lang === null
|
|
||||||
? undefined
|
|
||||||
: translations[lang][this.name];
|
|
||||||
},
|
|
||||||
getNormalizedDate() {
|
|
||||||
return toUtcTimestamp(this.date);
|
|
||||||
},
|
|
||||||
equals(otherDate) {
|
|
||||||
const dateString = localeDateObjectToDateString(otherDate);
|
|
||||||
return this.dateString === dateString;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param date
|
|
||||||
* @returns {string}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function localeDateObjectToDateString(date) {
|
|
||||||
const normalizedDate = new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000);
|
|
||||||
normalizedDate.setUTCHours(0, 0, 0, 0);
|
|
||||||
return normalizedDate.toISOString().slice(0, 10);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns the UTC timestamp of the given date with hours, minutes, seconds, and milliseconds set to zero.
|
|
||||||
* @param date
|
|
||||||
* @returns {number} UTC timestamp
|
|
||||||
*/
|
|
||||||
function toUtcTimestamp(date) {
|
|
||||||
const internalDate = new Date(date);
|
|
||||||
internalDate.setHours(0, 0, 0, 0);
|
|
||||||
return internalDate.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.addTranslation = addTranslation;
|
|
||||||
exports.getHolidayByDate = getHolidayByDate;
|
|
||||||
exports.getHolidays = getHolidays;
|
|
||||||
exports.getLanguage = getLanguage;
|
|
||||||
exports.isHoliday = isHoliday;
|
|
||||||
exports.isSpecificHoliday = isSpecificHoliday;
|
|
||||||
exports.isSunOrHoliday = isSunOrHoliday;
|
|
||||||
exports.setLanguage = setLanguage;
|
|
||||||
|
|
||||||
}));
|
|
||||||
//# sourceMappingURL=feiertage.umd.cjs.map
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"feiertage.umd.cjs","sources":["../src/german-translations.ts","../src/holiday-type.ts","../src/regions.ts","../src/feiertage.ts"],"sourcesContent":["import { TranslationTable } from './feiertage';\n\nexport const germanTranslations: TranslationTable = {\n NEUJAHRSTAG: 'Neujahrstag',\n HEILIGEDREIKOENIGE: 'Heilige Drei Könige',\n KARFREITAG: 'Karfreitag',\n OSTERSONNTAG: 'Ostersonntag',\n OSTERMONTAG: 'Ostermontag',\n TAG_DER_ARBEIT: 'Tag der Arbeit',\n CHRISTIHIMMELFAHRT: 'Christi Himmelfahrt',\n PFINGSTSONNTAG: 'Pfingstsonntag',\n PFINGSTMONTAG: 'Pfingstmontag',\n FRONLEICHNAM: 'Fronleichnam',\n MARIAHIMMELFAHRT: 'Mariä Himmelfahrt',\n DEUTSCHEEINHEIT: 'Tag der Deutschen Einheit',\n REFORMATIONSTAG: 'Reformationstag',\n ALLERHEILIGEN: 'Allerheiligen',\n BUBETAG: 'Buß- und Bettag',\n ERSTERWEIHNACHTSFEIERTAG: '1. Weihnachtstag',\n ZWEITERWEIHNACHTSFEIERTAG: '2. Weihnachtstag',\n WELTKINDERTAG: 'Weltkindertag',\n WELTFRAUENTAG: 'Weltfrauentag',\n AUGSBURGER_FRIEDENSFEST: 'Augsburger Friedensfest',\n};\n","export type HolidayType =\n | 'NEUJAHRSTAG'\n | 'HEILIGEDREIKOENIGE'\n | 'KARFREITAG'\n | 'OSTERSONNTAG'\n | 'OSTERMONTAG'\n | 'TAG_DER_ARBEIT'\n | 'CHRISTIHIMMELFAHRT'\n | 'MARIAHIMMELFAHRT'\n | 'PFINGSTSONNTAG'\n | 'PFINGSTMONTAG'\n | 'FRONLEICHNAM'\n | 'DEUTSCHEEINHEIT'\n | 'REFORMATIONSTAG'\n | 'ALLERHEILIGEN'\n | 'BUBETAG'\n | 'ERSTERWEIHNACHTSFEIERTAG'\n | 'ZWEITERWEIHNACHTSFEIERTAG'\n | 'WELTKINDERTAG'\n | 'WELTFRAUENTAG'\n | 'AUGSBURGER_FRIEDENSFEST';\n\nexport const allHolidays: HolidayType[] = [\n 'NEUJAHRSTAG',\n 'HEILIGEDREIKOENIGE',\n 'KARFREITAG',\n 'OSTERSONNTAG',\n 'OSTERMONTAG',\n 'TAG_DER_ARBEIT',\n 'CHRISTIHIMMELFAHRT',\n 'MARIAHIMMELFAHRT',\n 'PFINGSTSONNTAG',\n 'PFINGSTMONTAG',\n 'FRONLEICHNAM',\n 'DEUTSCHEEINHEIT',\n 'REFORMATIONSTAG',\n 'ALLERHEILIGEN',\n 'BUBETAG',\n 'ERSTERWEIHNACHTSFEIERTAG',\n 'ZWEITERWEIHNACHTSFEIERTAG',\n 'WELTKINDERTAG',\n 'WELTFRAUENTAG',\n 'AUGSBURGER_FRIEDENSFEST',\n];\n","export type Region =\n | 'BW' // Baden-Württemberg\n | 'BY' // Bayern\n | 'BE' // Berlin\n | 'BB' // Brandenburg\n | 'HB' // Bremen\n | 'HE' // Hessen\n | 'HH' // Hamburg\n | 'MV' // Mecklenburg-Vorpommern\n | 'NI' // Niedersachsen\n | 'NW' // Nordrhein-Westfalen\n | 'RP' // Rheinland-Pfalz\n | 'SL' // Saarland\n | 'SN' // Sachsen\n | 'ST' // Sachsen-Anhalt\n | 'SH' // Schleswig-Holstein\n | 'TH' // Thüringen\n | 'BUND' // Gesamt-Deutschland\n // Custom regions with local holidays (incompelte) !\n | 'AUGSBURG'\n | 'ALL';\n\nexport const allRegions: Region[] = [\n 'BW',\n 'BY',\n 'BE',\n 'BB',\n 'HB',\n 'HE',\n 'HH',\n 'MV',\n 'NI',\n 'NW',\n 'RP',\n 'SL',\n 'SN',\n 'ST',\n 'SH',\n 'TH',\n 'BUND',\n 'AUGSBURG',\n 'ALL',\n];\n","/*!\n * feiertage.js\n * @repository https://github.com/sfakir/feiertagejs\n * @docs https://github.com/sfakir/feiertagejs/blob/master/docs.md\n *\n * Copyright 2015-2021 Simon Fakir\n * Released under the MIT license\n */\n\n//\n// Additional readings\n// - how to format a javascript date: http://blog.stevenlevithan.com/archives/date-time-format\n// - the right javascript date: http://stackoverflow.com/questions/10286204/the-right-json-date-format\n//\n\nimport { germanTranslations } from './german-translations';\nimport { Holiday } from './holiday';\nimport { allHolidays, HolidayType } from './holiday-type';\nimport { allRegions, Region } from './regions';\n\n// translations\n\nconst defaultLanguage = 'de';\nlet currentLanguage: string = defaultLanguage;\n\n/**\n * Map of {@link HolidayType} to translation string.\n */\nexport type TranslationTable = { [key in HolidayType]?: string };\n\nconst translations: { [key: string]: TranslationTable } = {\n de: germanTranslations,\n};\n\n/**\n * adds a translation for the holidays (e.g. english).\n * This also allows to override the German names.\n * Hint: Interpolates German for missing translations\n * @param {string} isoCode of the new language\n * @param {TranslationTable} newTranslation map of {HolidayType} to translation stringg\n */\nexport function addTranslation(\n isoCode: string,\n newTranslation: TranslationTable,\n): void {\n const code = isoCode.toLowerCase();\n const defaultTranslation = translations[defaultLanguage];\n let missingFields = false;\n\n // fill new Translation with default Language\n for (const holiday of allHolidays) {\n if (!newTranslation[holiday]) {\n missingFields = true;\n newTranslation[holiday] = defaultTranslation[holiday];\n }\n }\n if (missingFields) {\n console.warn(\n '[feiertagejs] addTranslation: you did not add all holidays in your translation! Took German as fallback',\n );\n }\n\n translations[code] = newTranslation;\n}\n\n/**\n * Set a language to default language\n * @param {string} isoCode\n */\nexport function setLanguage(isoCode: string): void {\n const code = isoCode.toLowerCase();\n if (!translations[code]Line truncated
|
|
||||||
-496
@@ -1,496 +0,0 @@
|
|||||||
(function (global, factory) {
|
|
||||||
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
|
|
||||||
typeof define === 'function' && define.amd ? define(['exports'], factory) :
|
|
||||||
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, (function () {
|
|
||||||
var current = global.feiertagejs;
|
|
||||||
var exports = global.feiertagejs = {};
|
|
||||||
factory(exports);
|
|
||||||
exports.noConflict = function () { global.feiertagejs = current; return exports; };
|
|
||||||
})());
|
|
||||||
})(this, (function (exports) { 'use strict';
|
|
||||||
|
|
||||||
const germanTranslations = {
|
|
||||||
NEUJAHRSTAG: 'Neujahrstag',
|
|
||||||
HEILIGEDREIKOENIGE: 'Heilige Drei Könige',
|
|
||||||
KARFREITAG: 'Karfreitag',
|
|
||||||
OSTERSONNTAG: 'Ostersonntag',
|
|
||||||
OSTERMONTAG: 'Ostermontag',
|
|
||||||
TAG_DER_ARBEIT: 'Tag der Arbeit',
|
|
||||||
CHRISTIHIMMELFAHRT: 'Christi Himmelfahrt',
|
|
||||||
PFINGSTSONNTAG: 'Pfingstsonntag',
|
|
||||||
PFINGSTMONTAG: 'Pfingstmontag',
|
|
||||||
FRONLEICHNAM: 'Fronleichnam',
|
|
||||||
MARIAHIMMELFAHRT: 'Mariä Himmelfahrt',
|
|
||||||
DEUTSCHEEINHEIT: 'Tag der Deutschen Einheit',
|
|
||||||
REFORMATIONSTAG: 'Reformationstag',
|
|
||||||
ALLERHEILIGEN: 'Allerheiligen',
|
|
||||||
BUBETAG: 'Buß- und Bettag',
|
|
||||||
ERSTERWEIHNACHTSFEIERTAG: '1. Weihnachtstag',
|
|
||||||
ZWEITERWEIHNACHTSFEIERTAG: '2. Weihnachtstag',
|
|
||||||
WELTKINDERTAG: 'Weltkindertag',
|
|
||||||
WELTFRAUENTAG: 'Weltfrauentag',
|
|
||||||
AUGSBURGER_FRIEDENSFEST: 'Augsburger Friedensfest',
|
|
||||||
};
|
|
||||||
|
|
||||||
const allHolidays = [
|
|
||||||
'NEUJAHRSTAG',
|
|
||||||
'HEILIGEDREIKOENIGE',
|
|
||||||
'KARFREITAG',
|
|
||||||
'OSTERSONNTAG',
|
|
||||||
'OSTERMONTAG',
|
|
||||||
'TAG_DER_ARBEIT',
|
|
||||||
'CHRISTIHIMMELFAHRT',
|
|
||||||
'MARIAHIMMELFAHRT',
|
|
||||||
'PFINGSTSONNTAG',
|
|
||||||
'PFINGSTMONTAG',
|
|
||||||
'FRONLEICHNAM',
|
|
||||||
'DEUTSCHEEINHEIT',
|
|
||||||
'REFORMATIONSTAG',
|
|
||||||
'ALLERHEILIGEN',
|
|
||||||
'BUBETAG',
|
|
||||||
'ERSTERWEIHNACHTSFEIERTAG',
|
|
||||||
'ZWEITERWEIHNACHTSFEIERTAG',
|
|
||||||
'WELTKINDERTAG',
|
|
||||||
'WELTFRAUENTAG',
|
|
||||||
'AUGSBURGER_FRIEDENSFEST',
|
|
||||||
];
|
|
||||||
|
|
||||||
const allRegions = [
|
|
||||||
'BW',
|
|
||||||
'BY',
|
|
||||||
'BE',
|
|
||||||
'BB',
|
|
||||||
'HB',
|
|
||||||
'HE',
|
|
||||||
'HH',
|
|
||||||
'MV',
|
|
||||||
'NI',
|
|
||||||
'NW',
|
|
||||||
'RP',
|
|
||||||
'SL',
|
|
||||||
'SN',
|
|
||||||
'ST',
|
|
||||||
'SH',
|
|
||||||
'TH',
|
|
||||||
'BUND',
|
|
||||||
'AUGSBURG',
|
|
||||||
'ALL',
|
|
||||||
];
|
|
||||||
|
|
||||||
/*!
|
|
||||||
* feiertage.js
|
|
||||||
* @repository https://github.com/sfakir/feiertagejs
|
|
||||||
* @docs https://github.com/sfakir/feiertagejs/blob/master/docs.md
|
|
||||||
*
|
|
||||||
* Copyright 2015-2021 Simon Fakir
|
|
||||||
* Released under the MIT license
|
|
||||||
*/
|
|
||||||
// translations
|
|
||||||
const defaultLanguage = 'de';
|
|
||||||
let currentLanguage = defaultLanguage;
|
|
||||||
const translations = {
|
|
||||||
de: germanTranslations,
|
|
||||||
};
|
|
||||||
/**
|
|
||||||
* adds a translation for the holidays (e.g. english).
|
|
||||||
* This also allows to override the German names.
|
|
||||||
* Hint: Interpolates German for missing translations
|
|
||||||
* @param {string} isoCode of the new language
|
|
||||||
* @param {TranslationTable} newTranslation map of {HolidayType} to translation stringg
|
|
||||||
*/
|
|
||||||
function addTranslation(isoCode, newTranslation) {
|
|
||||||
const code = isoCode.toLowerCase();
|
|
||||||
const defaultTranslation = translations[defaultLanguage];
|
|
||||||
let missingFields = false;
|
|
||||||
// fill new Translation with default Language
|
|
||||||
for (const holiday of allHolidays) {
|
|
||||||
if (!newTranslation[holiday]) {
|
|
||||||
missingFields = true;
|
|
||||||
newTranslation[holiday] = defaultTranslation[holiday];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (missingFields) {
|
|
||||||
console.warn('[feiertagejs] addTranslation: you did not add all holidays in your translation! Took German as fallback');
|
|
||||||
}
|
|
||||||
translations[code] = newTranslation;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Set a language to default language
|
|
||||||
* @param {string} isoCode
|
|
||||||
*/
|
|
||||||
function setLanguage(isoCode) {
|
|
||||||
const code = isoCode.toLowerCase();
|
|
||||||
if (!translations[code]) {
|
|
||||||
throw new TypeError(`[feiertagejs] tried to set language to ${code} but the translation is missing. Please use addTranslation(isoCode,object) first`);
|
|
||||||
}
|
|
||||||
currentLanguage = isoCode;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Get currently set language
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
function getLanguage() {
|
|
||||||
return currentLanguage;
|
|
||||||
}
|
|
||||||
// holidays api
|
|
||||||
/**
|
|
||||||
* Checks if a specific date is sunday or holiday.
|
|
||||||
* @param date
|
|
||||||
* @param region
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
function isSunOrHoliday(date, region) {
|
|
||||||
checkRegion(region);
|
|
||||||
return date.getDay() === 0 || isHoliday(date, region);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Check is specific date is holiday.
|
|
||||||
* @param date
|
|
||||||
* @param {Region} region two character {@link Region} code
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
function isHoliday(date, region) {
|
|
||||||
checkRegion(region);
|
|
||||||
const year = date.getFullYear();
|
|
||||||
const internalDate = toUtcTimestamp(date);
|
|
||||||
const holidays = getHolidaysAsUtcTimestamps(year, region);
|
|
||||||
return holidays.indexOf(internalDate) !== -1;
|
|
||||||
}
|
|
||||||
function getHolidayByDate(date, region = 'ALL') {
|
|
||||||
checkRegion(region);
|
|
||||||
const holidays = getHolidaysOfYear(date.getFullYear(), region);
|
|
||||||
return holidays.find((holiday) => holiday.equals(date));
|
|
||||||
}
|
|
||||||
// additional runtime checks
|
|
||||||
/**
|
|
||||||
* Checks if the given region is a valid {@link Region}.
|
|
||||||
*
|
|
||||||
* @param region {@link Region} to check
|
|
||||||
* @throws {Error}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function checkRegion(region) {
|
|
||||||
if (region === null || region === undefined) {
|
|
||||||
throw new Error(`Region must not be undefined or null`);
|
|
||||||
}
|
|
||||||
if (allRegions.indexOf(region) === -1) {
|
|
||||||
throw new Error(`Invalid region: ${region}! Must be one of ${allRegions.toString()}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Checks if the given holidayName is a valid {@link HolidayType}.
|
|
||||||
* @param holidayName {@link HolidayType} to check
|
|
||||||
* @throws {Error}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function checkHolidayType(holidayName) {
|
|
||||||
if (holidayName === null || holidayName === undefined) {
|
|
||||||
throw new TypeError('holidayName must not be null or undefined');
|
|
||||||
}
|
|
||||||
if (allHolidays.indexOf(holidayName) === -1) {
|
|
||||||
throw new Error(`feiertage.js: invalid holiday type "${holidayName}"! Must be one of ${allHolidays.toString()}`);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function isSpecificHoliday(date, holidayName, region = 'ALL') {
|
|
||||||
checkRegion(region);
|
|
||||||
checkHolidayType(holidayName);
|
|
||||||
const holidays = getHolidaysOfYear(date.getFullYear(), region);
|
|
||||||
const foundHoliday = holidays.find((holiday) => holiday.equals(date));
|
|
||||||
if (!foundHoliday) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
return foundHoliday.name === holidayName;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns all holidays of a year in a {@link Region}.
|
|
||||||
* @param year
|
|
||||||
* @param region
|
|
||||||
* @returns {Array.<Holiday>}
|
|
||||||
*/
|
|
||||||
function getHolidays(year, region) {
|
|
||||||
let y;
|
|
||||||
if (typeof year === 'string') {
|
|
||||||
y = parseInt(year, 10);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
y = year;
|
|
||||||
}
|
|
||||||
checkRegion(region);
|
|
||||||
return getHolidaysOfYear(y, region);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {number} year
|
|
||||||
* @param region
|
|
||||||
* @returns {number[]}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getHolidaysAsUtcTimestamps(year, region) {
|
|
||||||
const holidays = getHolidaysOfYear(year, region);
|
|
||||||
return holidays.map((holiday) => toUtcTimestamp(holiday.date));
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param {number} year
|
|
||||||
* @param region
|
|
||||||
* @returns {{objects: Array.<Holiday>, integers}}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getHolidaysOfYear(year, region) {
|
|
||||||
const easterDate = getEasterDate(year);
|
|
||||||
const karfreitag = addDays(new Date(easterDate.getTime()), -2);
|
|
||||||
const ostermontag = addDays(new Date(easterDate.getTime()), 1);
|
|
||||||
const christiHimmelfahrt = addDays(new Date(easterDate.getTime()), 39);
|
|
||||||
const pfingstsonntag = addDays(new Date(easterDate.getTime()), 49);
|
|
||||||
const pfingstmontag = addDays(new Date(easterDate.getTime()), 50);
|
|
||||||
const holidays = [
|
|
||||||
...getCommonHolidays(year),
|
|
||||||
newHoliday('KARFREITAG', karfreitag),
|
|
||||||
newHoliday('OSTERMONTAG', ostermontag),
|
|
||||||
newHoliday('CHRISTIHIMMELFAHRT', christiHimmelfahrt),
|
|
||||||
newHoliday('PFINGSTMONTAG', pfingstmontag),
|
|
||||||
];
|
|
||||||
addHeiligeDreiKoenige(year, region, holidays);
|
|
||||||
addEasterAndPfingsten(year, region, easterDate, pfingstsonntag, holidays);
|
|
||||||
addFronleichnam(region, easterDate, holidays);
|
|
||||||
addMariaeHimmelfahrt(year, region, holidays);
|
|
||||||
addReformationstag(year, region, holidays);
|
|
||||||
addAllerheiligen(year, region, holidays);
|
|
||||||
addBussUndBetttag(year, region, holidays);
|
|
||||||
addWeltkindertag(year, region, holidays);
|
|
||||||
addWeltfrauenTag(year, region, holidays);
|
|
||||||
addRegionalHolidays(year, region, holidays);
|
|
||||||
return holidays.sort((a, b) => a.date.getTime() - b.date.getTime());
|
|
||||||
}
|
|
||||||
function getCommonHolidays(year) {
|
|
||||||
return [
|
|
||||||
newHoliday('NEUJAHRSTAG', makeDate(year, 1, 1)),
|
|
||||||
newHoliday('TAG_DER_ARBEIT', makeDate(year, 5, 1)),
|
|
||||||
newHoliday('DEUTSCHEEINHEIT', makeDate(year, 10, 3)),
|
|
||||||
newHoliday('ERSTERWEIHNACHTSFEIERTAG', makeDate(year, 12, 25)),
|
|
||||||
newHoliday('ZWEITERWEIHNACHTSFEIERTAG', makeDate(year, 12, 26)),
|
|
||||||
];
|
|
||||||
}
|
|
||||||
function addRegionalHolidays(year, region, feiertageObjects) {
|
|
||||||
if (region === 'AUGSBURG') {
|
|
||||||
feiertageObjects.push(newHoliday('AUGSBURGER_FRIEDENSFEST', makeDate(year, 8, 8)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addHeiligeDreiKoenige(year, region, feiertageObjects) {
|
|
||||||
if (region === 'BW' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'ST' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
feiertageObjects.push(newHoliday('HEILIGEDREIKOENIGE', makeDate(year, 1, 6)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addEasterAndPfingsten(year, region, easterDate, pfingstsonntag, feiertageObjects) {
|
|
||||||
if (region === 'BB' || region === 'ALL') {
|
|
||||||
feiertageObjects.push(newHoliday('OSTERSONNTAG', easterDate), newHoliday('PFINGSTSONNTAG', pfingstsonntag));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addFronleichnam(region, easterDate, holidays) {
|
|
||||||
if (region === 'BW' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'HE' ||
|
|
||||||
region === 'NW' ||
|
|
||||||
region === 'RP' ||
|
|
||||||
region === 'SL' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
const fronleichnam = addDays(new Date(easterDate.getTime()), 60);
|
|
||||||
holidays.push(newHoliday('FRONLEICHNAM', fronleichnam));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addMariaeHimmelfahrt(year, region, holidays) {
|
|
||||||
if (region === 'SL' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
holidays.push(newHoliday('MARIAHIMMELFAHRT', makeDate(year, 8, 15)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addReformationstag(year, region, holidays) {
|
|
||||||
if (year === 2017 ||
|
|
||||||
region === 'NI' ||
|
|
||||||
region === 'BB' ||
|
|
||||||
region === 'HB' ||
|
|
||||||
region === 'HH' ||
|
|
||||||
region === 'MV' ||
|
|
||||||
region === 'SN' ||
|
|
||||||
region === 'ST' ||
|
|
||||||
region === 'TH' ||
|
|
||||||
region === 'SH' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
holidays.push(newHoliday('REFORMATIONSTAG', makeDate(year, 10, 31)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addAllerheiligen(year, region, holidays) {
|
|
||||||
if (region === 'BW' ||
|
|
||||||
region === 'BY' ||
|
|
||||||
region === 'AUGSBURG' ||
|
|
||||||
region === 'NW' ||
|
|
||||||
region === 'RP' ||
|
|
||||||
region === 'SL' ||
|
|
||||||
region === 'ALL') {
|
|
||||||
holidays.push(newHoliday('ALLERHEILIGEN', makeDate(year, 11, 1)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addBussUndBetttag(year, region, holidays) {
|
|
||||||
if (region === 'SN' || region === 'ALL') {
|
|
||||||
// @todo write test
|
|
||||||
const bussbettag = getBussBettag(year);
|
|
||||||
holidays.push(newHoliday('BUBETAG', makeDate(bussbettag.getUTCFullYear(), bussbettag.getUTCMonth() + 1, bussbettag.getUTCDate())));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addWeltkindertag(year, region, holidays) {
|
|
||||||
if (year >= 2019 && (region === 'TH' || region === 'ALL')) {
|
|
||||||
holidays.push(newHoliday('WELTKINDERTAG', makeDate(year, 9, 20)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
function addWeltfrauenTag(year, region, feiertageObjects) {
|
|
||||||
if (year <= 2018) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (region === 'BE' || region === 'ALL') {
|
|
||||||
// in Berlin ist der Weltfrauentag ein Feiertag seit 2018
|
|
||||||
feiertageObjects.push(newHoliday('WELTFRAUENTAG', makeDate(year, 3, 8)));
|
|
||||||
}
|
|
||||||
if (region === 'MV' && year >= 2023) {
|
|
||||||
// in MV wird der Weltfrauentag erst ab 2023 eingeführt
|
|
||||||
feiertageObjects.push(newHoliday('WELTFRAUENTAG', makeDate(year, 3, 8)));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Calculates the Easter date of a given year.
|
|
||||||
* @param year {number}
|
|
||||||
* @returns {Date} Easter date
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getEasterDate(year) {
|
|
||||||
const C = Math.floor(year / 100);
|
|
||||||
// tslint:disable:binary-expression-operand-order
|
|
||||||
// tslint generates false positives in the following blocks
|
|
||||||
const N = year - 19 * Math.floor(year / 19);
|
|
||||||
const K = Math.floor((C - 17) / 25);
|
|
||||||
let I = C - Math.floor(C / 4) - Math.floor((C - K) / 3) + 19 * N + 15;
|
|
||||||
I -= 30 * Math.floor(I / 30);
|
|
||||||
I -=
|
|
||||||
Math.floor(I / 28) *
|
|
||||||
(1 -
|
|
||||||
Math.floor(I / 28) *
|
|
||||||
Math.floor(29 / (I + 1)) *
|
|
||||||
Math.floor((21 - N) / 11));
|
|
||||||
let J = year + Math.floor(year / 4) + I + 2 - C + Math.floor(C / 4);
|
|
||||||
J -= 7 * Math.floor(J / 7);
|
|
||||||
const L = I - J;
|
|
||||||
const M = 3 + Math.floor((L + 40) / 44);
|
|
||||||
const D = L + 28 - 31 * Math.floor(M / 4);
|
|
||||||
// tslint:enable:binary-expression-operand-order
|
|
||||||
return new Date(year, M - 1, D);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Computes the "Buss- und Bettag"'s date.
|
|
||||||
* @param jahr {number}
|
|
||||||
* @returns {Date} the year's "Buss- und Bettag" date
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function getBussBettag(jahr) {
|
|
||||||
const weihnachten = new Date(jahr, 11, 25, 12, 0, 0);
|
|
||||||
const ersterAdventOffset = 32;
|
|
||||||
let wochenTagOffset = weihnachten.getDay() % 7;
|
|
||||||
if (wochenTagOffset === 0) {
|
|
||||||
wochenTagOffset = 7;
|
|
||||||
}
|
|
||||||
const tageVorWeihnachten = wochenTagOffset + ersterAdventOffset;
|
|
||||||
let bbtag = new Date(weihnachten.getTime());
|
|
||||||
bbtag = addDays(bbtag, -tageVorWeihnachten);
|
|
||||||
return bbtag;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Adds {@code days} days to the given {@link Date}.
|
|
||||||
* @param date
|
|
||||||
* @param days
|
|
||||||
* @returns {Date}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function addDays(date, days) {
|
|
||||||
const changedDate = new Date(date);
|
|
||||||
changedDate.setDate(date.getDate() + days);
|
|
||||||
return changedDate;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Creates a new {@link Date}.
|
|
||||||
* @param year
|
|
||||||
* @param naturalMonth month (1-12)
|
|
||||||
* @param day
|
|
||||||
* @returns {Date}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function makeDate(year, naturalMonth, day) {
|
|
||||||
return new Date(year, naturalMonth - 1, day);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param name
|
|
||||||
* @param date
|
|
||||||
* @returns {Holiday}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function newHoliday(name, date) {
|
|
||||||
return {
|
|
||||||
name,
|
|
||||||
date,
|
|
||||||
dateString: localeDateObjectToDateString(date),
|
|
||||||
trans(lang = currentLanguage) {
|
|
||||||
console.warn('FeiertageJs: You are using "Holiday.trans() method. This will be replaced in the next major version with translate()"');
|
|
||||||
return this.translate(lang);
|
|
||||||
},
|
|
||||||
translate(lang = currentLanguage) {
|
|
||||||
return lang === undefined || lang === null
|
|
||||||
? undefined
|
|
||||||
: translations[lang][this.name];
|
|
||||||
},
|
|
||||||
getNormalizedDate() {
|
|
||||||
return toUtcTimestamp(this.date);
|
|
||||||
},
|
|
||||||
equals(otherDate) {
|
|
||||||
const dateString = localeDateObjectToDateString(otherDate);
|
|
||||||
return this.dateString === dateString;
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* @param date
|
|
||||||
* @returns {string}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
function localeDateObjectToDateString(date) {
|
|
||||||
const normalizedDate = new Date(date.getTime() - date.getTimezoneOffset() * 60 * 1000);
|
|
||||||
normalizedDate.setUTCHours(0, 0, 0, 0);
|
|
||||||
return normalizedDate.toISOString().slice(0, 10);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* Returns the UTC timestamp of the given date with hours, minutes, seconds, and milliseconds set to zero.
|
|
||||||
* @param date
|
|
||||||
* @returns {number} UTC timestamp
|
|
||||||
*/
|
|
||||||
function toUtcTimestamp(date) {
|
|
||||||
const internalDate = new Date(date);
|
|
||||||
internalDate.setHours(0, 0, 0, 0);
|
|
||||||
return internalDate.getTime();
|
|
||||||
}
|
|
||||||
|
|
||||||
exports.addTranslation = addTranslation;
|
|
||||||
exports.getHolidayByDate = getHolidayByDate;
|
|
||||||
exports.getHolidays = getHolidays;
|
|
||||||
exports.getLanguage = getLanguage;
|
|
||||||
exports.isHoliday = isHoliday;
|
|
||||||
exports.isSpecificHoliday = isSpecificHoliday;
|
|
||||||
exports.isSunOrHoliday = isSunOrHoliday;
|
|
||||||
exports.setLanguage = setLanguage;
|
|
||||||
|
|
||||||
}));
|
|
||||||
//# sourceMappingURL=feiertage.umd.js.map
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
{"version":3,"file":"feiertage.umd.js","sources":["../src/german-translations.ts","../src/holiday-type.ts","../src/regions.ts","../src/feiertage.ts"],"sourcesContent":["import { TranslationTable } from './feiertage';\n\nexport const germanTranslations: TranslationTable = {\n NEUJAHRSTAG: 'Neujahrstag',\n HEILIGEDREIKOENIGE: 'Heilige Drei Könige',\n KARFREITAG: 'Karfreitag',\n OSTERSONNTAG: 'Ostersonntag',\n OSTERMONTAG: 'Ostermontag',\n TAG_DER_ARBEIT: 'Tag der Arbeit',\n CHRISTIHIMMELFAHRT: 'Christi Himmelfahrt',\n PFINGSTSONNTAG: 'Pfingstsonntag',\n PFINGSTMONTAG: 'Pfingstmontag',\n FRONLEICHNAM: 'Fronleichnam',\n MARIAHIMMELFAHRT: 'Mariä Himmelfahrt',\n DEUTSCHEEINHEIT: 'Tag der Deutschen Einheit',\n REFORMATIONSTAG: 'Reformationstag',\n ALLERHEILIGEN: 'Allerheiligen',\n BUBETAG: 'Buß- und Bettag',\n ERSTERWEIHNACHTSFEIERTAG: '1. Weihnachtstag',\n ZWEITERWEIHNACHTSFEIERTAG: '2. Weihnachtstag',\n WELTKINDERTAG: 'Weltkindertag',\n WELTFRAUENTAG: 'Weltfrauentag',\n AUGSBURGER_FRIEDENSFEST: 'Augsburger Friedensfest',\n};\n","export type HolidayType =\n | 'NEUJAHRSTAG'\n | 'HEILIGEDREIKOENIGE'\n | 'KARFREITAG'\n | 'OSTERSONNTAG'\n | 'OSTERMONTAG'\n | 'TAG_DER_ARBEIT'\n | 'CHRISTIHIMMELFAHRT'\n | 'MARIAHIMMELFAHRT'\n | 'PFINGSTSONNTAG'\n | 'PFINGSTMONTAG'\n | 'FRONLEICHNAM'\n | 'DEUTSCHEEINHEIT'\n | 'REFORMATIONSTAG'\n | 'ALLERHEILIGEN'\n | 'BUBETAG'\n | 'ERSTERWEIHNACHTSFEIERTAG'\n | 'ZWEITERWEIHNACHTSFEIERTAG'\n | 'WELTKINDERTAG'\n | 'WELTFRAUENTAG'\n | 'AUGSBURGER_FRIEDENSFEST';\n\nexport const allHolidays: HolidayType[] = [\n 'NEUJAHRSTAG',\n 'HEILIGEDREIKOENIGE',\n 'KARFREITAG',\n 'OSTERSONNTAG',\n 'OSTERMONTAG',\n 'TAG_DER_ARBEIT',\n 'CHRISTIHIMMELFAHRT',\n 'MARIAHIMMELFAHRT',\n 'PFINGSTSONNTAG',\n 'PFINGSTMONTAG',\n 'FRONLEICHNAM',\n 'DEUTSCHEEINHEIT',\n 'REFORMATIONSTAG',\n 'ALLERHEILIGEN',\n 'BUBETAG',\n 'ERSTERWEIHNACHTSFEIERTAG',\n 'ZWEITERWEIHNACHTSFEIERTAG',\n 'WELTKINDERTAG',\n 'WELTFRAUENTAG',\n 'AUGSBURGER_FRIEDENSFEST',\n];\n","export type Region =\n | 'BW' // Baden-Württemberg\n | 'BY' // Bayern\n | 'BE' // Berlin\n | 'BB' // Brandenburg\n | 'HB' // Bremen\n | 'HE' // Hessen\n | 'HH' // Hamburg\n | 'MV' // Mecklenburg-Vorpommern\n | 'NI' // Niedersachsen\n | 'NW' // Nordrhein-Westfalen\n | 'RP' // Rheinland-Pfalz\n | 'SL' // Saarland\n | 'SN' // Sachsen\n | 'ST' // Sachsen-Anhalt\n | 'SH' // Schleswig-Holstein\n | 'TH' // Thüringen\n | 'BUND' // Gesamt-Deutschland\n // Custom regions with local holidays (incompelte) !\n | 'AUGSBURG'\n | 'ALL';\n\nexport const allRegions: Region[] = [\n 'BW',\n 'BY',\n 'BE',\n 'BB',\n 'HB',\n 'HE',\n 'HH',\n 'MV',\n 'NI',\n 'NW',\n 'RP',\n 'SL',\n 'SN',\n 'ST',\n 'SH',\n 'TH',\n 'BUND',\n 'AUGSBURG',\n 'ALL',\n];\n","/*!\n * feiertage.js\n * @repository https://github.com/sfakir/feiertagejs\n * @docs https://github.com/sfakir/feiertagejs/blob/master/docs.md\n *\n * Copyright 2015-2021 Simon Fakir\n * Released under the MIT license\n */\n\n//\n// Additional readings\n// - how to format a javascript date: http://blog.stevenlevithan.com/archives/date-time-format\n// - the right javascript date: http://stackoverflow.com/questions/10286204/the-right-json-date-format\n//\n\nimport { germanTranslations } from './german-translations';\nimport { Holiday } from './holiday';\nimport { allHolidays, HolidayType } from './holiday-type';\nimport { allRegions, Region } from './regions';\n\n// translations\n\nconst defaultLanguage = 'de';\nlet currentLanguage: string = defaultLanguage;\n\n/**\n * Map of {@link HolidayType} to translation string.\n */\nexport type TranslationTable = { [key in HolidayType]?: string };\n\nconst translations: { [key: string]: TranslationTable } = {\n de: germanTranslations,\n};\n\n/**\n * adds a translation for the holidays (e.g. english).\n * This also allows to override the German names.\n * Hint: Interpolates German for missing translations\n * @param {string} isoCode of the new language\n * @param {TranslationTable} newTranslation map of {HolidayType} to translation stringg\n */\nexport function addTranslation(\n isoCode: string,\n newTranslation: TranslationTable,\n): void {\n const code = isoCode.toLowerCase();\n const defaultTranslation = translations[defaultLanguage];\n let missingFields = false;\n\n // fill new Translation with default Language\n for (const holiday of allHolidays) {\n if (!newTranslation[holiday]) {\n missingFields = true;\n newTranslation[holiday] = defaultTranslation[holiday];\n }\n }\n if (missingFields) {\n console.warn(\n '[feiertagejs] addTranslation: you did not add all holidays in your translation! Took German as fallback',\n );\n }\n\n translations[code] = newTranslation;\n}\n\n/**\n * Set a language to default language\n * @param {string} isoCode\n */\nexport function setLanguage(isoCode: string): void {\n const code = isoCode.toLowerCase();\n if (!translations[code])Line truncated
|
|
||||||
-144
@@ -1,144 +0,0 @@
|
|||||||
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
|
|
||||||
|
|
||||||
### Table of Contents
|
|
||||||
|
|
||||||
*Types*
|
|
||||||
- [HolidayType](#holidaytype)
|
|
||||||
- [Region](#region)
|
|
||||||
- [Holiday](#holiday)
|
|
||||||
- [allHolidays](#allholidays)
|
|
||||||
- [allRegions](#allregions)
|
|
||||||
- [TranslationTable](#translationtable)
|
|
||||||
|
|
||||||
*API*
|
|
||||||
- [isHoliday(date, region)](#isholiday)
|
|
||||||
- [getHolidayByDate(date, region)](#getholidaybydate)
|
|
||||||
- [getHolidays(year, region)](#getholidays)
|
|
||||||
- [isSunOrHoliday(date, region)](#issunorholiday)
|
|
||||||
- [isSpecificHoliday(date, name, region)](#isspecificholiday)
|
|
||||||
- [addTranslation(isoCode, translation)](#addtranslation)
|
|
||||||
- [setLanguage(lng)](#setlanguage)
|
|
||||||
- [getLanguage()](#getlanguage)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
## Types
|
|
||||||
|
|
||||||
### HolidayType
|
|
||||||
|
|
||||||
Type: (`"NEUJAHRSTAG"` \| `"HEILIGEDREIKOENIGE"` \| `"KARFREITAG"` \| `"OSTERSONNTAG"` \| `"OSTERMONTAG"` \| `"TAG_DER_ARBEIT"` \| `"CHRISTIHIMMELFAHRT"` \| `"MARIAHIMMELFAHRT"` \| `"PFINGSTSONNTAG"` \| `"PFINGSTMONTAG"` \| `"FRONLEICHNAM"` \| `"DEUTSCHEEINHEIT"` \| `"REFORMATIONSTAG"` \| `"ALLERHEILIGEN"` \| `"BUBETAG"` \| `"ERSTERWEIHNACHTSFEIERTAG"` \| `"ZWEITERWEIHNACHTSFEIERTAG"` \| `"WELTKINDERTAG"` \| `"WELTFRAUENTAG"` \| `"AUGSBURGER_FRIEDENSFEST"`)
|
|
||||||
|
|
||||||
### Region
|
|
||||||
|
|
||||||
Type: (`"BW"` \| `"BY"` \| `"BE"` \| `"BB"` \| `"HB"` \| `"HE"` \| `"HH"` \| `"MV"` \| `"NI"` \| `"NW"` \| `"RP"` \| `"SL"` \| `"SN"` \| `"ST"` \| `"SH"` \| `"TH"` \| `"BUND"` \| `"ALL"`)
|
|
||||||
|
|
||||||
As defined here: https://de.wikipedia.org/wiki/Land_(Deutschland)#Amtliche_bzw._Eigenbezeichnungen
|
|
||||||
|
|
||||||
The difference between BUND and ALL is defined as follows:
|
|
||||||
* "ALL" refers to every holiday which is valid in **at least** one region. So a holiday that only applies to one state will be included.
|
|
||||||
* "BUND" refers to holidays that are valid in every region ("bundesweit"). So a holiday that only applies to one state will not be included.
|
|
||||||
|
|
||||||
### Holiday
|
|
||||||
|
|
||||||
Type: {name: [HolidayType](#holidaytype), date: [Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date), trans: function (lang: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?): [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), dateString: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String), equals: function (date: [Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)): [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)}
|
|
||||||
|
|
||||||
**Properties**
|
|
||||||
|
|
||||||
- `name` **[HolidayType](#holidaytype)**
|
|
||||||
- `date` **[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)**
|
|
||||||
- `trans` **function (lang: [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)?): [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
||||||
- `dateString` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
||||||
- `equals` **function (date: [Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)): [boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**
|
|
||||||
|
|
||||||
### allHolidays
|
|
||||||
|
|
||||||
Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[HolidayType](#holidaytype)>
|
|
||||||
|
|
||||||
### allRegions
|
|
||||||
|
|
||||||
Type: [Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Region](#region)>
|
|
||||||
|
|
||||||
### TranslationTable
|
|
||||||
|
|
||||||
Map of [HolidayType](#holidaytype) to translation string.
|
|
||||||
|
|
||||||
Type: {}
|
|
||||||
|
|
||||||
|
|
||||||
## API
|
|
||||||
### addTranslation()
|
|
||||||
|
|
||||||
Adds a translation for the holidays (e.g. English).
|
|
||||||
This also allows overriding the German names.
|
|
||||||
Hint: Interpolates German for missing translations
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `isoCode` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)** of the new language
|
|
||||||
- `newTranslation` **[TranslationTable](#translationtable)** map of {HolidayType} to translation stringg
|
|
||||||
|
|
||||||
### setLanguage()
|
|
||||||
|
|
||||||
Set a language to default language
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `isoCode` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
||||||
|
|
||||||
### getLanguage()
|
|
||||||
|
|
||||||
Get currently set language
|
|
||||||
|
|
||||||
Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**
|
|
||||||
|
|
||||||
### isSunOrHoliday()
|
|
||||||
|
|
||||||
Checks if a specific date is sunday or holiday.
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `date` **[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)**
|
|
||||||
- `region` **[Region](#region)**
|
|
||||||
|
|
||||||
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**
|
|
||||||
|
|
||||||
### isHoliday()
|
|
||||||
|
|
||||||
Check is specific date is holiday.
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `date` **[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)**
|
|
||||||
- `region` **[Region](#region)** two character [Region](#region) code
|
|
||||||
|
|
||||||
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**
|
|
||||||
|
|
||||||
### getHolidayByDate()
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `date` **[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)**
|
|
||||||
- `region` **[Region](#region)** (optional, default `'ALL'`)
|
|
||||||
|
|
||||||
Returns **([Holiday](#holiday) | void)**
|
|
||||||
|
|
||||||
### isSpecificHoliday()
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `date` **[Date](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Date)**
|
|
||||||
- `holidayName` **[HolidayType](#holidaytype)**
|
|
||||||
- `region` **[Region](#region)** (optional, default `'ALL'`)
|
|
||||||
|
|
||||||
Returns **[boolean](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean)**
|
|
||||||
|
|
||||||
### getHolidays()
|
|
||||||
|
|
||||||
Returns all holidays of a year in a [Region](#region).
|
|
||||||
|
|
||||||
**Parameters**
|
|
||||||
|
|
||||||
- `year` **([number](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))**
|
|
||||||
- `region` **[Region](#region)**
|
|
||||||
|
|
||||||
Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Holiday](#holiday)>**
|
|
||||||
-113
@@ -1,113 +0,0 @@
|
|||||||
declare type Region =
|
|
||||||
| 'BW' // Baden-Württemberg
|
|
||||||
| 'BY' // Bayern
|
|
||||||
| 'BE' // Berlin
|
|
||||||
| 'BB' // Brandenburg
|
|
||||||
| 'HB' // Bremen
|
|
||||||
| 'HE' // Hessen
|
|
||||||
| 'HH' // Hamburg
|
|
||||||
| 'MV' // Mecklenburg-Vorpommern
|
|
||||||
| 'NI' // Niedersachsen
|
|
||||||
| 'NW' // Nordrhein-Westfalen
|
|
||||||
| 'RP' // Rheinland-Pfalz
|
|
||||||
| 'SL' // Saarland
|
|
||||||
| 'SN' // Sachsen
|
|
||||||
| 'ST' // Sachsen-Anhalt
|
|
||||||
| 'SH' // Schleswig-Holstein
|
|
||||||
| 'TH' // Thüringen
|
|
||||||
| 'BUND' // Gesamt-Deutschland
|
|
||||||
| 'AUGSBURG'
|
|
||||||
| 'ALL';
|
|
||||||
|
|
||||||
declare type Holiday = {
|
|
||||||
name: HolidayType;
|
|
||||||
date: Date;
|
|
||||||
trans?: (lang: string | undefined) => string; // deprecated;
|
|
||||||
translate: (lang?: string | undefined) => string;
|
|
||||||
dateString: string;
|
|
||||||
equals: (date: Date) => boolean;
|
|
||||||
};
|
|
||||||
|
|
||||||
declare type HolidayType =
|
|
||||||
| 'NEUJAHRSTAG'
|
|
||||||
| 'HEILIGEDREIKOENIGE'
|
|
||||||
| 'KARFREITAG'
|
|
||||||
| 'OSTERSONNTAG'
|
|
||||||
| 'OSTERMONTAG'
|
|
||||||
| 'TAG_DER_ARBEIT'
|
|
||||||
| 'CHRISTIHIMMELFAHRT'
|
|
||||||
| 'MARIAHIMMELFAHRT'
|
|
||||||
| 'PFINGSTSONNTAG'
|
|
||||||
| 'PFINGSTMONTAG'
|
|
||||||
| 'FRONLEICHNAM'
|
|
||||||
| 'DEUTSCHEEINHEIT'
|
|
||||||
| 'REFORMATIONSTAG'
|
|
||||||
| 'ALLERHEILIGEN'
|
|
||||||
| 'BUBETAG'
|
|
||||||
| 'ERSTERWEIHNACHTSFEIERTAG'
|
|
||||||
| 'ZWEITERWEIHNACHTSFEIERTAG';
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Map of {@link HolidayType} to translation string.
|
|
||||||
*/
|
|
||||||
export type TranslationTable = {
|
|
||||||
[key: string]: string;
|
|
||||||
};
|
|
||||||
|
|
||||||
/**
|
|
||||||
* adds a translation for the holidays (e.g. english).
|
|
||||||
* This also allows to override the German names.
|
|
||||||
* Hint: Interpolates German for missing translations
|
|
||||||
* @param {string} isoCode of the new language
|
|
||||||
* @param {TranslationTable} newTranslation map of {HolidayType} to translation stringg
|
|
||||||
*/
|
|
||||||
declare function addTranslation(
|
|
||||||
isoCode: string,
|
|
||||||
newTranslation: TranslationTable,
|
|
||||||
): void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Set a language to default language
|
|
||||||
* @param {string} isoCode
|
|
||||||
*/
|
|
||||||
declare function setLanguage(isoCode: string): void;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get currently set language
|
|
||||||
* @returns {string}
|
|
||||||
*/
|
|
||||||
declare function getLanguage(): string;
|
|
||||||
|
|
||||||
// holidays api
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a specific date is sunday or holiday.
|
|
||||||
* @param date
|
|
||||||
* @param region
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
declare function isSunOrHoliday(date: Date, region: Region): boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check is specific date is holiday.
|
|
||||||
* @param date
|
|
||||||
* @param {Region} region two character {@link Region} code
|
|
||||||
* @returns {boolean}
|
|
||||||
*/
|
|
||||||
declare function isHoliday(date: Date, region: Region): boolean;
|
|
||||||
|
|
||||||
declare function getHolidayByDate(date: Date, region: Region): Holiday | void;
|
|
||||||
|
|
||||||
declare function isSpecificHoliday(
|
|
||||||
date: Date,
|
|
||||||
holidayName: HolidayType,
|
|
||||||
region: Region,
|
|
||||||
): boolean;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns all holidays of a year in a {@link Region}.
|
|
||||||
* @param year
|
|
||||||
* @param region
|
|
||||||
* @returns {Array.<Holiday>}
|
|
||||||
*/
|
|
||||||
declare function getHolidays(year: number | string, region: Region): Holiday[];
|
|
||||||
-53
@@ -1,53 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "feiertagejs",
|
|
||||||
"version": "1.3.9",
|
|
||||||
"description": "A module to calculate German holidays made for node.js",
|
|
||||||
"type": "module",
|
|
||||||
"main": "build/feiertage.umd.cjs",
|
|
||||||
"module": "build/feiertage.js",
|
|
||||||
"types": "index.d.ts",
|
|
||||||
"scripts": {
|
|
||||||
"test": "vitest run --coverage",
|
|
||||||
"test:w": "vitest watch",
|
|
||||||
"format": "prettier --write \"{**/*,*}.{ts,json}\" \"!coverage/**\" \"!build/**\" \"!package.json\" \"!package-lock.json\" --cache",
|
|
||||||
"lint": "eslint \"src\" \"spec\"",
|
|
||||||
"build": "rollup -c"
|
|
||||||
},
|
|
||||||
"repository": {
|
|
||||||
"type": "git",
|
|
||||||
"url": "https://github.com/sfakir/feiertagejs"
|
|
||||||
},
|
|
||||||
"keywords": [
|
|
||||||
"node",
|
|
||||||
"holidays",
|
|
||||||
"feiertage",
|
|
||||||
"javascript"
|
|
||||||
],
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8.0.0"
|
|
||||||
},
|
|
||||||
"author": "Simon Fakir",
|
|
||||||
"license": "MIT",
|
|
||||||
"bugs": {
|
|
||||||
"url": "https://github.com/sfakir/feiertagejs/issues"
|
|
||||||
},
|
|
||||||
"homepage": "https://github.com/sfakir/feiertagejs",
|
|
||||||
"devDependencies": {
|
|
||||||
"@vitest/coverage-c8": "^0.26.2",
|
|
||||||
"prettier": "^2.8.1",
|
|
||||||
"rollup": "^3.9.0",
|
|
||||||
"@rollup/plugin-typescript": "^10.0.1",
|
|
||||||
"typescript": "^4.9.4",
|
|
||||||
"vitest": "^0.26.2",
|
|
||||||
"@typescript-eslint/eslint-plugin": "^5.47.1",
|
|
||||||
"@typescript-eslint/parser": "^5.47.1",
|
|
||||||
"eslint": "^8.30.0",
|
|
||||||
"eslint-config-prettier": "^8.5.0"
|
|
||||||
},
|
|
||||||
"files": [
|
|
||||||
"build",
|
|
||||||
"docs.md",
|
|
||||||
"Readme.md",
|
|
||||||
"index.d.ts"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
Generated
-20
@@ -1,20 +0,0 @@
|
|||||||
{
|
|
||||||
"name": "TIF22A_AnwProjekt_B",
|
|
||||||
"lockfileVersion": 3,
|
|
||||||
"requires": true,
|
|
||||||
"packages": {
|
|
||||||
"": {
|
|
||||||
"dependencies": {
|
|
||||||
"feiertagejs": "^1.3.9"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"node_modules/feiertagejs": {
|
|
||||||
"version": "1.3.9",
|
|
||||||
"resolved": "https://registry.npmjs.org/feiertagejs/-/feiertagejs-1.3.9.tgz",
|
|
||||||
"integrity": "sha512-tUP+WBv2OWBhPwe3NfqwCtjMq+ym598a42tfqmL0FySswEb9xs96p2iKwqqx+lxKieu1njJBRZKsFm92bJhxZw==",
|
|
||||||
"engines": {
|
|
||||||
"node": ">=8.0.0"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
{
|
|
||||||
"dependencies": {
|
|
||||||
"feiertagejs": "^1.3.9"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in new issue
Block a user