Kalender Side Bar Bugfix
Noch etwas Bugfix + neue Funktionalität hinzugefügt :)
This commit is contained in:
@@ -4,10 +4,10 @@ const months = [["Januar", 31], ["Februar", 28], ["März", 31], ["April", 30], [
|
||||
const days = months.map((month => month[1]))
|
||||
let result = []
|
||||
let check = true
|
||||
const weekdays = ["Sonntag", "Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag"]
|
||||
const weekdays = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"]
|
||||
export default function BasicDateCalendar(p) {
|
||||
if (check) {
|
||||
generateCalendar("01.11.2023", "15.01.2024")
|
||||
generateCalendar("01.12.2024", "15.09.2025")
|
||||
check = false
|
||||
}
|
||||
return (
|
||||
@@ -16,6 +16,9 @@ export default function BasicDateCalendar(p) {
|
||||
<div key={months} className={"A"}>
|
||||
<p>{getMonthName(index)}</p>
|
||||
<div className={"Days"}>
|
||||
{weekdays.map((weekday) => (
|
||||
<p key={weekday}>{weekday}</p>
|
||||
))}
|
||||
{monthResult.map((date) => (
|
||||
<p key={date}>{date}</p>
|
||||
))}
|
||||
@@ -34,6 +37,7 @@ function getMonthName(monthIndex) {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function generateCalendar(start, ende)
|
||||
{
|
||||
splitter(start, ende)
|
||||
@@ -45,8 +49,8 @@ function generateCalendar(start, ende)
|
||||
for (let j = 1; j <= days[i]; j++)
|
||||
{
|
||||
if (
|
||||
new Date(2023, i, j) >= new Date(2023, startParts[1] - 1, startParts[0]) &&
|
||||
new Date(2023, i, j) <= new Date(2023, 11, 31)
|
||||
new Date(startParts[2], i, j) >= new Date(startParts[2], startParts[1] - 1, startParts[0]) &&
|
||||
new Date(startParts[2], i, j) <= new Date(startParts[2], 11, 31)
|
||||
)
|
||||
{
|
||||
monthResult.push(j);
|
||||
@@ -60,7 +64,7 @@ function generateCalendar(start, ende)
|
||||
let monthResultNewYear = [];
|
||||
for (let g = 1; g <= days[h]; g++)
|
||||
{
|
||||
if (new Date(2024, h, g) <= new Date(2024, endParts[1] - 1, endParts[0]))
|
||||
if (new Date(endParts[2], h, g) <= new Date(endParts[2], endParts[1] - 1, endParts[0]))
|
||||
{
|
||||
monthResultNewYear.push(g);
|
||||
}
|
||||
@@ -77,8 +81,8 @@ function generateCalendar(start, ende)
|
||||
for (let j = 1; j <= days[i]; j++)
|
||||
{
|
||||
if (
|
||||
new Date(2023, i, j) >= new Date(2023, startParts[1] - 1, startParts[0]) &&
|
||||
new Date(2023, i, j) <= new Date(2023, endParts[1] - 1, endParts[0])
|
||||
new Date(startParts[2], i, j) >= new Date(startParts[2], startParts[1] - 1, startParts[0]) &&
|
||||
new Date(startParts[2], i, j) <= new Date(startParts[2], endParts[1] - 1, endParts[0])
|
||||
)
|
||||
{
|
||||
monthResult.push(j);
|
||||
@@ -92,7 +96,7 @@ function generateCalendar(start, ende)
|
||||
function splitter(startDate, endDate)
|
||||
{
|
||||
startParts = startDate.split(".")
|
||||
//Test()
|
||||
//Transformer()
|
||||
if (startParts[1][0] === 0) //prüft ob die erste Stelle des Monats eine 0 vorne stehen hat
|
||||
{
|
||||
startParts[1] = startParts[1][1] //überschreibt den Monat ohne die 0
|
||||
@@ -104,7 +108,7 @@ function splitter(startDate, endDate)
|
||||
}
|
||||
}
|
||||
|
||||
function Test()
|
||||
function Transformer()
|
||||
{
|
||||
let formattedDateStr = startParts[1] + "/" + startParts[0] + "/" + startParts[2];
|
||||
console.log(formattedDateStr)
|
||||
|
||||
Reference in New Issue
Block a user