Function Status Bar and Time Validation
This commit is contained in:
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",
|
||||
"dependencies": {
|
||||
"autoprefixer": "10.4.14",
|
||||
"feiertagejs": "^1.3.9",
|
||||
"next": "13.3.4",
|
||||
"postcss": "8.4.23",
|
||||
"react": "18.2.0",
|
||||
@@ -530,6 +531,14 @@
|
||||
"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": {
|
||||
"version": "7.0.1",
|
||||
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
},
|
||||
"dependencies": {
|
||||
"autoprefixer": "10.4.14",
|
||||
"feiertagejs": "^1.3.9",
|
||||
"next": "13.3.4",
|
||||
"postcss": "8.4.23",
|
||||
"react": "18.2.0",
|
||||
|
||||
@@ -7,6 +7,8 @@ import {baseURL} from "@/components/Constants";
|
||||
import {ErrorType} from "@/components/ErrorType";
|
||||
import BasicDateCalendar from "@/components/CalendarSideBar";
|
||||
import feiertagejs from "feiertagejs";
|
||||
import PopUp from "@/components/PopUp";
|
||||
import {useRouter} from "next/router";
|
||||
|
||||
let cellHeight = 20;
|
||||
|
||||
@@ -19,6 +21,8 @@ let currentYear;
|
||||
let semesterStartYear;
|
||||
let semesterEndYear;
|
||||
let selectedElement;
|
||||
let lastEndTimeDrag;
|
||||
let lastStartTimeDrag;
|
||||
let grabbedDown;
|
||||
|
||||
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 grayedOut = [false, false, false, false, false, false]
|
||||
|
||||
let timePlanned = 0
|
||||
|
||||
export default function CalenderView(p) {
|
||||
|
||||
const [entries, setEntries] = useState([[], [], [], [], [], []])
|
||||
@@ -38,6 +44,8 @@ export default function CalenderView(p) {
|
||||
const [endYearCalenderSideBar, setEndYearCalenderSideBar] = useState(2000)
|
||||
const [highlightMonth, setHighlightMonth] = useState(0)
|
||||
const [highlightYear, setHighlightYear] = useState(2000)
|
||||
const [popUpToggleAbgeben, setPopUpToggleAbgeben] = useState(false)
|
||||
const router = useRouter();
|
||||
|
||||
|
||||
function readEntries() {
|
||||
@@ -110,8 +118,7 @@ export default function CalenderView(p) {
|
||||
if (en[i][k] != null) {
|
||||
|
||||
|
||||
if (en[i][k].semesterid != currentsid)
|
||||
{
|
||||
if (en[i][k].semesterid != currentsid) {
|
||||
for (let l = 0; l < 20; l++) {
|
||||
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) {
|
||||
@@ -153,6 +160,26 @@ export default function CalenderView(p) {
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -228,6 +255,18 @@ export default function CalenderView(p) {
|
||||
let id = selectedElement.id;
|
||||
|
||||
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 json = {
|
||||
"id": id,
|
||||
@@ -235,8 +274,8 @@ export default function CalenderView(p) {
|
||||
"yearnumber": 0,
|
||||
"semesterid": 0,
|
||||
"usercreatedbyid": 0,
|
||||
"timestart": selectedElement.timestart,
|
||||
"timeend": selectedElement.timeend,
|
||||
"timestart": finalTimeStart,
|
||||
"timeend": finalTimeEnd,
|
||||
"info": "",
|
||||
"moduleid": localStorage.getItem("moduleid")
|
||||
}
|
||||
@@ -316,7 +355,7 @@ export default function CalenderView(p) {
|
||||
if (!currentId.includes("grab")) {
|
||||
if (!checkForElementAtRow(row + 2, currentColumnID) && !checkForElementAtRow(row + 1, currentColumnID)) {
|
||||
if ((row - 1) / 4 >= 7 && (row + 2) / 4 <= 18) {
|
||||
if (!grayedOut[currentColumnID]) {
|
||||
if (!grayedOut[currentColumnID] && timePlanned + 0.8 < 20) {
|
||||
pushEntry(currentColumnID, row)
|
||||
}
|
||||
}
|
||||
@@ -326,6 +365,8 @@ export default function CalenderView(p) {
|
||||
if (currentUserID == getElementInColumn(parentID, currentColumnID).usercreatedbyid && getElementInColumn(parentID, currentColumnID).moduleid == localStorage.getItem("moduleid")) {
|
||||
grabbedDown = currentId.includes("down")
|
||||
selectedElement = getElementInColumn(parentID, currentColumnID);
|
||||
lastEndTimeDrag = selectedElement.timeend
|
||||
lastStartTimeDrag = selectedElement.timestart
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -366,19 +407,25 @@ export default function CalenderView(p) {
|
||||
}
|
||||
|
||||
function getEntryColor(userCreatedByID, columnID, semesterid, moduleid) {
|
||||
console.log(moduleid)
|
||||
let id = localStorage.getItem("userid");
|
||||
let currentsid = localStorage.getItem("currentsid")
|
||||
if (id == userCreatedByID) {
|
||||
if (isDayOkay[columnID] && moduleid == localStorage.getItem("moduleid")) {
|
||||
return "#77932b";
|
||||
} else if (moduleid != localStorage.getItem("moduleid")) {
|
||||
return "#346991";
|
||||
} else {
|
||||
return "#e5a10e";
|
||||
}
|
||||
if(localStorage.getItem("admin") == 0)
|
||||
{
|
||||
if (id == userCreatedByID) {
|
||||
if (isDayOkay[columnID] && moduleid == localStorage.getItem("moduleid")) {
|
||||
return "#77932b";
|
||||
} else if (moduleid != localStorage.getItem("moduleid")) {
|
||||
return "#346991";
|
||||
} else {
|
||||
return "#e5a10e";
|
||||
}
|
||||
|
||||
} else {
|
||||
} else {
|
||||
return "#a2a2a2";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return "#a2a2a2";
|
||||
}
|
||||
}
|
||||
@@ -386,74 +433,83 @@ export default function CalenderView(p) {
|
||||
function getResizeBarColor(userCreatedByID, columnID, semesterid, moduleid) {
|
||||
let id = localStorage.getItem("userid");
|
||||
let currentsid = localStorage.getItem("currentsid")
|
||||
if (id == userCreatedByID) {
|
||||
if (isDayOkay[columnID] && moduleid == localStorage.getItem("moduleid")) {
|
||||
return "#5a6c20";
|
||||
} else if (moduleid != localStorage.getItem("moduleid")) {
|
||||
return "#346991"
|
||||
if(localStorage.getItem("admin") == 0)
|
||||
{
|
||||
if (id == userCreatedByID) {
|
||||
if (isDayOkay[columnID] && moduleid == localStorage.getItem("moduleid")) {
|
||||
return "#5a6c20";
|
||||
} else if (moduleid != localStorage.getItem("moduleid")) {
|
||||
return "#346991"
|
||||
} else {
|
||||
return "#c08809";
|
||||
}
|
||||
} else {
|
||||
return "#c08809";
|
||||
return "#a2a2a2";
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return "#a2a2a2";
|
||||
}
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
semesterStart = 0;
|
||||
semesterEnd = 0;
|
||||
semesterStartYear = 0;
|
||||
semesterEndYear = 0;
|
||||
currentWeekStartDay = 0;
|
||||
currentYear = 2000;
|
||||
selectedElement = null;
|
||||
grabbedDown = false;
|
||||
errorState = [ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay]
|
||||
setTimeout(() => {
|
||||
semesterStart = 0;
|
||||
semesterEnd = 0;
|
||||
semesterStartYear = 0;
|
||||
semesterEndYear = 0;
|
||||
currentWeekStartDay = 0;
|
||||
currentYear = 2000;
|
||||
selectedElement = null;
|
||||
grabbedDown = false;
|
||||
errorState = [ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay, ErrorType.Okay]
|
||||
|
||||
let url = baseURL + "/semester/id?sessionid=" + localStorage.getItem("sessionid") +
|
||||
"&id=" + localStorage.getItem("currentsid");
|
||||
let url = baseURL + "/semester/id?sessionid=" + localStorage.getItem("sessionid") +
|
||||
"&id=" + localStorage.getItem("currentsid");
|
||||
|
||||
|
||||
fetch(url).then(r => r.json()).then(s => {
|
||||
currentWeekStartDay = s.startday - new Date(s.startyear, 0, s.startday).getUTCDay();
|
||||
currentYear = s.startyear;
|
||||
setStartYearCalenderSideBar(currentYear)
|
||||
setEndYearCalenderSideBar(s.endyear)
|
||||
setHighlightMonth(new Date(s.startyear, 0, s.startday).getMonth())
|
||||
setHighlightYear(currentYear)
|
||||
fetch(url).then(r => r.json()).then(s => {
|
||||
currentWeekStartDay = s.startday - new Date(s.startyear, 0, s.startday).getUTCDay();
|
||||
currentYear = s.startyear;
|
||||
setStartYearCalenderSideBar(currentYear)
|
||||
setEndYearCalenderSideBar(s.endyear)
|
||||
setHighlightMonth(new Date(s.startyear, 0, s.startday).getMonth())
|
||||
setHighlightYear(currentYear)
|
||||
|
||||
semesterStart = s.startday;
|
||||
semesterEnd = s.endday;
|
||||
semesterStartYear = s.startyear;
|
||||
semesterEndYear = s.endyear;
|
||||
setStartDayCalenderSideBar(semesterStart)
|
||||
setEndDayCalenderSideBar(s.endday)
|
||||
semesterStart = s.startday;
|
||||
semesterEnd = s.endday;
|
||||
semesterStartYear = s.startyear;
|
||||
semesterEndYear = s.endyear;
|
||||
setStartDayCalenderSideBar(semesterStart)
|
||||
setEndDayCalenderSideBar(s.endday)
|
||||
|
||||
}).then(readEntries)
|
||||
}).then(readEntries)
|
||||
|
||||
scrollRef.current.scrollTop = 600;
|
||||
window.addEventListener("contextmenu", (e) => (e.preventDefault()))
|
||||
scrollRef.current.scrollTop = 600;
|
||||
window.addEventListener("contextmenu", (e) => (e.preventDefault()))
|
||||
|
||||
window.addEventListener("keypress", (e) => {
|
||||
try {
|
||||
if (e.key === "+") {
|
||||
cellHeight += 2
|
||||
} else if (e.key === "-") {
|
||||
if (cellHeight - 2 >= 8) {
|
||||
cellHeight -= 2
|
||||
window.addEventListener("keypress", (e) => {
|
||||
try {
|
||||
if (e.key === "+") {
|
||||
cellHeight += 2
|
||||
} else if (e.key === "-") {
|
||||
if (cellHeight - 2 >= 8) {
|
||||
cellHeight -= 2
|
||||
}
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
} catch (e) {
|
||||
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
setInterval(function () {
|
||||
if (selectedElement == null) {
|
||||
readEntries()
|
||||
}
|
||||
}, 500);
|
||||
setInterval(function () {
|
||||
if (selectedElement == null) {
|
||||
readEntries()
|
||||
}
|
||||
}, 500);
|
||||
}, 100)
|
||||
}, [])
|
||||
|
||||
|
||||
@@ -498,6 +554,19 @@ export default function CalenderView(p) {
|
||||
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
|
||||
@@ -837,6 +906,24 @@ export default function CalenderView(p) {
|
||||
</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>
|
||||
)
|
||||
}
|
||||
@@ -1,20 +0,0 @@
|
||||
import {baseURL} from "@/components/Constants";
|
||||
|
||||
export default function HourCounter(){
|
||||
|
||||
function countTimePlanned(){
|
||||
const entryurl = baseURL + "/entries/module?moduleid=" + localStorage.getItem("moduleid") + "&sessionid=" + localStorage.getItem("sessionid");
|
||||
let hoursPlanned = 0
|
||||
|
||||
fetch(entryurl).then(response => response.json()).then(entries => {
|
||||
entries.forEach(e => {
|
||||
hoursPlanned += (e.timeend - e.timestart)/4;
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
console.log(20-countTimePlanned());
|
||||
|
||||
return(<p></p>);
|
||||
|
||||
}
|
||||
@@ -34,23 +34,29 @@ export default function InputForm(p) {
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
let base = baseURL + "/semester/id?sessionid=" + localStorage.getItem("sessionid") + "&id=" + localStorage.getItem("currentsid")
|
||||
fetch(base).then(r => r.json()).then(j => {
|
||||
setCourseName(j.name)
|
||||
setTimeout(() => {
|
||||
update = false;
|
||||
baseMapping = []
|
||||
|
||||
let tempStartDate = new Date(parseInt(j.startyear), 0, parseInt(j.startday))
|
||||
let tempEndDate = new Date(parseInt(j.endyear), 0, parseInt(j.endday))
|
||||
let base = baseURL + "/semester/id?sessionid=" + localStorage.getItem("sessionid") + "&id=" + localStorage.getItem("currentsid")
|
||||
fetch(base).then(r => r.json()).then(j => {
|
||||
|
||||
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"))
|
||||
tempSemesterNumber = j.number
|
||||
setSemesterNumber(j.number)
|
||||
|
||||
setSemesterNumber(j.number)
|
||||
tempSemesterNumber = j.number
|
||||
|
||||
}).then(() => {
|
||||
readModules()
|
||||
update = true
|
||||
}).catch(() => readModules())
|
||||
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)
|
||||
|
||||
|
||||
}, [])
|
||||
@@ -103,9 +109,9 @@ export default function InputForm(p) {
|
||||
|
||||
setIsChecked(temp)
|
||||
setIsActivated(temp2)
|
||||
}).then(() => {
|
||||
setModulesSelectorValues(modulesDummy[tempSemesterNumber])
|
||||
})
|
||||
}).then(() => {
|
||||
setModulesSelectorValues(modulesDummy[tempSemesterNumber])
|
||||
})
|
||||
}
|
||||
|
||||
@@ -260,13 +266,12 @@ export default function InputForm(p) {
|
||||
|
||||
userModulesMapping[i].semesterid = semesterID
|
||||
setTimeout(() => {
|
||||
console.log(userModulesMapping[i])
|
||||
fetch(baseURL + "/module?sessionid=" + localStorage.getItem("sessionid"), {
|
||||
method: userModulesMapping[i].id === -1 ? "POST" : "PUT",
|
||||
headers: {"Content-Type": "application/json"},
|
||||
body: JSON.stringify(userModulesMapping[i])
|
||||
})
|
||||
}, i * 100)
|
||||
}, i * 200)
|
||||
|
||||
}
|
||||
})
|
||||
|
||||
@@ -9,7 +9,8 @@ export default function PopUp(p) {
|
||||
return (
|
||||
<>
|
||||
<div style={{
|
||||
display: p.displayState
|
||||
display: p.displayState,
|
||||
zIndex: 1000
|
||||
}}>
|
||||
|
||||
<div className={"modal-container"}>
|
||||
|
||||
@@ -1,8 +1,4 @@
|
||||
import StatusBar from "@/components/StatusBar";
|
||||
import React, {useEffect} from "react";
|
||||
import Button from "@/components/Button";
|
||||
import {deleteItem, editItem} from "@/components/Icons";
|
||||
|
||||
export default function SemesterTile(p)
|
||||
{
|
||||
let editable = true;
|
||||
|
||||
@@ -1,130 +1,15 @@
|
||||
import React, {useState, useEffect} from "react";
|
||||
import { baseURL } from "@/components/Constants";
|
||||
|
||||
export default function StatusBar(p) {
|
||||
const [index, setIndex] = useState(-1);
|
||||
if (p.module != null){
|
||||
const module = p.module;
|
||||
|
||||
useEffect(() => {
|
||||
const url = baseURL + "/entries/planned?sessionid=" + localStorage.getItem("sessionid");
|
||||
fetch(url)
|
||||
.then((response) => response.json())
|
||||
.then((entries) => {
|
||||
let newIndex = -1;
|
||||
if (entries !== null) {
|
||||
entries.forEach((e) => {
|
||||
if (e.moduleid == module.id) {
|
||||
if (module.activated == 0) {
|
||||
newIndex = 2;
|
||||
} else {
|
||||
if(newIndex < 1) {
|
||||
newIndex = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
if (newIndex === -1) {
|
||||
newIndex = 0;
|
||||
}
|
||||
}
|
||||
setIndex(newIndex);
|
||||
});
|
||||
}, [module.id, module.activated]);
|
||||
|
||||
}
|
||||
else if(p.semester != null){
|
||||
const semester = p.semester;
|
||||
// const [newIndex, setNewIndex] = useState(-1)
|
||||
const url = baseURL + "/entries/semester?semesterid=" + semester.id + "&sessionid=" + localStorage.getItem("sessionid");
|
||||
const moduleurl = baseURL + "/module/bysemesterid?sessionid=" + localStorage.getItem("sessionid") + "&semesterid=" + localStorage.getItem("currentsid");
|
||||
|
||||
useEffect(() => {
|
||||
|
||||
fetch(url)
|
||||
.then((response) => response.json())
|
||||
.then((entries) => {
|
||||
// let newIndex = -1
|
||||
if (entries !== null) {
|
||||
const moduleurl = baseURL + "/module/bysemesterid?sessionid=" + localStorage.getItem("sessionid") + "&semesterid=" + localStorage.getItem("currentsid");
|
||||
fetch(moduleurl).then(response => response.json()).then(modules => {
|
||||
// let newIndex = -1
|
||||
let modulesWithEntries = [];
|
||||
let isSubmitted = true;
|
||||
modules.forEach(m => {
|
||||
entries.forEach(e => {
|
||||
if (e.moduleid === m.id) {
|
||||
if (!modulesWithEntries.includes(m)) {
|
||||
modulesWithEntries.push(m)
|
||||
}
|
||||
}
|
||||
if (m.activated === 1) {
|
||||
isSubmitted = false;
|
||||
}
|
||||
})
|
||||
})
|
||||
|
||||
// entries.forEach(e => {
|
||||
//
|
||||
// const moduleurl = baseURL + "/module/bysemesterid?sessionid=" + localStorage.getItem("sessionid") + "&semesterid=" + localStorage.getItem("currentsid");
|
||||
// fetch(moduleurl).then(response => response.json()).then(modules => {
|
||||
// // let newIndex = -1
|
||||
// let modulesWithEntries = [];
|
||||
// let isSubmitted = true;
|
||||
// modules.forEach(m => {
|
||||
// if (e.moduleid === m.id){
|
||||
// if (!modulesWithEntries.includes(m)) {
|
||||
// modulesWithEntries.push(m)
|
||||
// }
|
||||
// }
|
||||
// if (m.activated === 1){
|
||||
// isSubmitted = false;
|
||||
// }
|
||||
// })
|
||||
// // const modulesWithoutEntries = modules.filter(element => !modulesWithEntries.includes(element));
|
||||
// // console.log(modulesWithoutEntries);
|
||||
// // if (modulesWithoutEntries.length === 0 && isSubmitted){
|
||||
// // newIndex = 2;
|
||||
// // console.log("newIndex: "+2)
|
||||
// // }
|
||||
// // else if(modulesWithEntries.length !== 0 && newIndex < 1 && newIndex <= -1){
|
||||
// // newIndex = 1;
|
||||
// // }
|
||||
// //
|
||||
// // if (newIndex == -1) {
|
||||
// // newIndex = 0;
|
||||
// // }
|
||||
// //
|
||||
// // setIndex(newIndex);
|
||||
// })
|
||||
// });
|
||||
let newIndex = -1
|
||||
const modulesWithoutEntries = modules.filter(element => !modulesWithEntries.includes(element));
|
||||
console.log(modulesWithoutEntries);
|
||||
if (modulesWithoutEntries.length === 0 && isSubmitted) {
|
||||
newIndex = 2;
|
||||
console.log("newIndex: " + 2)
|
||||
} else if (modulesWithEntries.length !== 0 && newIndex < 1 && newIndex <= -1) {
|
||||
newIndex = 1;
|
||||
}
|
||||
|
||||
if (newIndex == -1) {
|
||||
newIndex = 0;
|
||||
}
|
||||
|
||||
setIndex(newIndex);
|
||||
});
|
||||
}
|
||||
|
||||
});
|
||||
}, [semester.id, semester.activated]);
|
||||
|
||||
}
|
||||
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)
|
||||
{
|
||||
if(p.progress > 100) p.progress = 100;
|
||||
let classNames = ["not-started", "started", "finished"];
|
||||
let actives = ["", "", ""];
|
||||
actives[index] = "active";
|
||||
let index = p.progress / 50;
|
||||
|
||||
let actives = ["", "", ""]
|
||||
actives[index] = "active";
|
||||
|
||||
return (
|
||||
<div className={"step-container"}>
|
||||
@@ -132,13 +17,12 @@ export default function StatusBar(p) {
|
||||
<span className={"step " + classNames[0] + " " + actives[0]}>1</span>
|
||||
<span className={"step " + classNames[1] + " " + actives[1]}>2</span>
|
||||
<span className={"step " + classNames[2] + " " + actives[2]}>3</span>
|
||||
<div
|
||||
className={"progress-bar " + classNames[index]}
|
||||
style={{
|
||||
width: 100 + "%",
|
||||
}}
|
||||
<div className={"progress-bar " + classNames[index]}
|
||||
style={{
|
||||
width: p.progress + "%"
|
||||
}}
|
||||
></div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
)
|
||||
}
|
||||
@@ -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": localStorage.getItem("moduleid"),
|
||||
"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,7 +5,6 @@ import Back from "@/components/Back";
|
||||
import BasicDateCalendar from "@/components/CalendarSideBar";
|
||||
import {useRouter} from "next/router";
|
||||
import HelpButton from "@/components/HelpButton";
|
||||
import SubmitButton from "@/components/SubmitButton";
|
||||
|
||||
|
||||
export default function planning(p)
|
||||
@@ -26,7 +25,6 @@ export default function planning(p)
|
||||
<HelpButton/>
|
||||
<Background/>
|
||||
<CalenderView semesterName={semesterName}/>
|
||||
<SubmitButton />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -12,12 +12,76 @@ import StatusBar from "@/components/StatusBar";
|
||||
import {deleteItem, editItem} from "@/components/Icons";
|
||||
|
||||
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 allSemesters
|
||||
let allModules
|
||||
let allEntries
|
||||
|
||||
await fetch(urlTest).then(response => response.json()).then(s => {
|
||||
setEntries(s)
|
||||
allSemesters = s
|
||||
if (set) {
|
||||
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) {
|
||||
localStorage.setItem("currentsid", e.id)
|
||||
router.push("/planning")
|
||||
localStorage.setItem("semestername", e.name + " Sem. " + (e.number + 1))
|
||||
}
|
||||
|
||||
}
|
||||
@@ -56,7 +121,7 @@ export default function SemesterOverview(p) {
|
||||
});
|
||||
|
||||
togglePopup();
|
||||
getSemesters();
|
||||
getSemesters(true);
|
||||
}
|
||||
|
||||
async function funcButtonEdit(e, m) {
|
||||
@@ -80,13 +145,18 @@ export default function SemesterOverview(p) {
|
||||
endDate: endDate.toISOString().slice(0, 10)
|
||||
},
|
||||
});
|
||||
getSemesters();
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
getSemesters();
|
||||
|
||||
getSemesters(true);
|
||||
|
||||
}, [])
|
||||
useEffect(() => {
|
||||
setTimeout(() => {
|
||||
getSemesters(false)
|
||||
}, 1000)
|
||||
})
|
||||
|
||||
|
||||
const [entries, setEntries] = useState([])
|
||||
@@ -100,22 +170,23 @@ export default function SemesterOverview(p) {
|
||||
<HelpButton/>
|
||||
<Background/>
|
||||
{
|
||||
entries.map(e => (
|
||||
entries.map((e, index) => (
|
||||
<div className={"semester-tile box-shadow"} onClick={(f) => onClickSemester(e, f)}>
|
||||
<SemesterTile text={e.name} onClick={(f) => onClickSemester(e, f)} onButtonDeleteClick={() => {
|
||||
localStorage.setItem("currentsid", e.id)
|
||||
setModalHint(e.name + " Löschen?");
|
||||
togglePopup();
|
||||
}} onButtonEditClick={(m) => {
|
||||
<SemesterTile text={e.name + " Sem. " + (e.number + 1)} onClick={(f) => onClickSemester(e, f)}
|
||||
onButtonDeleteClick={() => {
|
||||
localStorage.setItem("currentsid", e.id)
|
||||
setModalHint(e.name + " Löschen?");
|
||||
togglePopup();
|
||||
}} onButtonEditClick={(m) => {
|
||||
localStorage.setItem("currentsid", e.id)
|
||||
funcButtonEdit(e, m);
|
||||
}}/>
|
||||
<StatusBar semester={e} module={null}/>
|
||||
<StatusBar progress={progresses[index]}/>
|
||||
<div style={
|
||||
{
|
||||
display:"flex",
|
||||
justifyContent:"center",
|
||||
alignItems:"center"
|
||||
display: "flex",
|
||||
justifyContent: "center",
|
||||
alignItems: "center"
|
||||
}
|
||||
}>
|
||||
<Button icon={deleteItem} width={30} height={30} color={"#ffffff"}
|
||||
|
||||
@@ -8,6 +8,9 @@ import HelpButton from "@/components/HelpButton";
|
||||
import StatusBar from "@/components/StatusBar";
|
||||
|
||||
export default function SemesteroverviewLecturer(p) {
|
||||
|
||||
const [timeStamps, setTimeStamps] = useState([])
|
||||
|
||||
function getModules() {
|
||||
let urlTest = baseURL + "/module/id?sessionid=" + localStorage.getItem("sessionid");
|
||||
|
||||
@@ -28,7 +31,30 @@ export default function SemesteroverviewLecturer(p) {
|
||||
sem.map(e => {
|
||||
temp.push(e.name + " Sem. " + (e.number + 1))
|
||||
})
|
||||
}).then(() => setSemesterNames(temp))
|
||||
}).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)
|
||||
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
}
|
||||
@@ -47,13 +73,32 @@ export default function SemesteroverviewLecturer(p) {
|
||||
|
||||
|
||||
useEffect(() => {
|
||||
getModules();
|
||||
setTimeout(() => {
|
||||
getModules();
|
||||
}, 1000)
|
||||
}, [])
|
||||
|
||||
const [entries, setEntries] = useState([]);
|
||||
const [semesterNames, setSemesterNames] = useState([]);
|
||||
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 (
|
||||
<div className={"semester-overview"}>
|
||||
@@ -68,7 +113,7 @@ export default function SemesteroverviewLecturer(p) {
|
||||
editable={false} text={semesterNames[index]} text2={e.name}
|
||||
onClick={(f) => onClickSemester(e, f, semesterNames[index])}
|
||||
/>
|
||||
<StatusBar module={e} semester={null}/>
|
||||
<StatusBar progress={getProgressForTime(timeStamps[index], e.activated)} module={e}/>
|
||||
</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>
|
||||
)
|
||||
}
|
||||
@@ -183,6 +183,7 @@ Step Progress Bar
|
||||
color: white;
|
||||
font-weight: bold;
|
||||
pointer-events: none;
|
||||
z-index: 101;
|
||||
}
|
||||
|
||||
.steps .not-started {
|
||||
@@ -213,7 +214,7 @@ Step Progress Bar
|
||||
position: absolute;
|
||||
height: 8px;
|
||||
background-color: #5d606e;
|
||||
z-index: -1;
|
||||
z-index: 100;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
@@ -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
|
||||
# Editor-based HTTP Client requests
|
||||
/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"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="" vcs="Git" />
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
||||
Binary file not shown.
+514805
File diff suppressed because it is too large
Load Diff
@@ -88,21 +88,6 @@ public class DataBaseHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public Entry[] getEntries(int userid, int moduleid){
|
||||
try{
|
||||
ResultSet rs = st.executeQuery("select * from entries where moduleid=" + moduleid);
|
||||
List<Entry> entryList = new ArrayList<>();
|
||||
Entry current = null;
|
||||
while ((current = resultSetToEntry(rs)) != null){
|
||||
entryList.add(current);
|
||||
}
|
||||
return entryList.toArray(new Entry[0]);
|
||||
}
|
||||
catch (Exception e){
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public Entry[][] getAllEntrys(int semesterid, int daynumber, int yearnumber, int userid) {
|
||||
try {
|
||||
@@ -133,40 +118,44 @@ public class DataBaseHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public Entry[] getAllEntries(int semesterid, int userid) {
|
||||
try {
|
||||
ResultSet rs = st.executeQuery("select * from entries where " +
|
||||
"semesterid=" + semesterid);
|
||||
List<Entry> entriestate = new ArrayList<>();
|
||||
Entry current = null;
|
||||
while ((current = resultSetToEntry(rs)) != null) {
|
||||
entriestate.add(current);
|
||||
}
|
||||
return entriestate.toArray(new Entry[0]);
|
||||
} catch (Exception e) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Entry[] getAllEntries(int userid)
|
||||
public Entry[] getAllEntries()
|
||||
{
|
||||
try {
|
||||
ResultSet rs = st.executeQuery("select * from entries where " +
|
||||
"usercreatedbyid=" + userid);
|
||||
ResultSet rs = st.executeQuery("select * from entries");
|
||||
List<Entry> entriestate = new ArrayList<>();
|
||||
Entry current = null;
|
||||
while((current = resultSetToEntry(rs)) != null)
|
||||
{
|
||||
entriestate.add(current);
|
||||
}
|
||||
Entry[] entryArray = new Entry[entriestate.toArray().length];
|
||||
return entriestate.toArray(entryArray);
|
||||
return entriestate.toArray(new Entry[0]);
|
||||
}catch (Exception e){
|
||||
System.out.println(e.getMessage());
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Entry[] getAllEntriesModule(int moduleid)
|
||||
{
|
||||
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);
|
||||
@@ -274,8 +263,8 @@ public class DataBaseHandler {
|
||||
public void deleteSemester(int id) {
|
||||
try {
|
||||
st.executeUpdate("DELETE FROM modules WHERE semesterid=" + id);
|
||||
|
||||
st.executeUpdate("delete from semester where id=" + id);
|
||||
st.executeUpdate("delete from entries where semesterid=" + id);
|
||||
} catch (Exception e) {
|
||||
|
||||
}
|
||||
@@ -381,9 +370,22 @@ public class DataBaseHandler {
|
||||
}
|
||||
}
|
||||
|
||||
public void submitModule(int id)
|
||||
{
|
||||
try
|
||||
{
|
||||
st.executeUpdate("update modules set activated=0 where id=" + id);
|
||||
}
|
||||
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;
|
||||
|
||||
@@ -59,13 +59,13 @@ public class EntriesController
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/entries/planned")
|
||||
@GetMapping("/entries/all")
|
||||
public ResponseEntity<Entry[]> getAllEntries(@RequestParam(name = "sessionid") String sessionid)
|
||||
{
|
||||
User sessionUser = UserSessionIDHandler.getUserBySessionID(sessionid);
|
||||
if (sessionUser != null)
|
||||
{
|
||||
var entries = db.getAllEntries(sessionUser.getId());
|
||||
var entries = db.getAllEntries();
|
||||
|
||||
return new ResponseEntity<>(entries, HttpStatus.OK);
|
||||
}
|
||||
@@ -73,27 +73,13 @@ public class EntriesController
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/entries/semester")
|
||||
public ResponseEntity<Entry[]> getEntriesInSemester(@RequestParam(name = "semesterid") int semesterid,
|
||||
@RequestParam(name = "sessionid") String sessionid){
|
||||
@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){
|
||||
Entry[] entries = db.getAllEntries(semesterid, sessionUser.getId());
|
||||
|
||||
return new ResponseEntity<>(entries, HttpStatus.OK);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/entries/module")
|
||||
public ResponseEntity<Entry[]> getEntries(@RequestParam(name = "moduleid") int moduleid,
|
||||
@RequestParam(name = "sessionid") String sessionid){
|
||||
User sessionUser = UserSessionIDHandler.getUserBySessionID(sessionid);
|
||||
if (sessionUser != null){
|
||||
Entry[] entries = db.getEntries(sessionUser.getId(), moduleid);
|
||||
|
||||
return new ResponseEntity<>(entries, HttpStatus.OK);
|
||||
if (sessionUser != null)
|
||||
{
|
||||
return new ResponseEntity<>(db.getAllEntriesModule(moduleid), HttpStatus.OK);
|
||||
}
|
||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ public class ModuleController
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
POST
|
||||
a new module entry. (When a user is selected in a semester.)
|
||||
@@ -149,6 +150,21 @@ public class ModuleController
|
||||
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 A Module
|
||||
|
||||
@@ -33,18 +33,6 @@ public class UserController {
|
||||
return new ResponseEntity<>(HttpStatus.FORBIDDEN);
|
||||
}
|
||||
|
||||
@CrossOrigin
|
||||
@GetMapping("/user")
|
||||
public ResponseEntity<User> getUser(@RequestParam(name = "sessionid") String sessionid){
|
||||
User u = UserSessionIDHandler.getUserBySessionID(sessionid);
|
||||
|
||||
if (u != null){
|
||||
return new ResponseEntity<>(u, HttpStatus.OK);
|
||||
}
|
||||
|
||||
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||
}
|
||||
|
||||
|
||||
//a user wants to login
|
||||
@CrossOrigin
|
||||
|
||||
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
|
||||
+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)
|
||||
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -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
File diff suppressed because one or more lines are too long
-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
File diff suppressed because one or more lines are too long
-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
File diff suppressed because one or more lines are too long
-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
File diff suppressed because one or more lines are too long
-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