Fix DayTypes

This commit is contained in:
2024-10-14 18:52:17 +02:00
parent 0b13955ffe
commit 22f24947ae
3 changed files with 812 additions and 230 deletions

1018
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -21,7 +21,7 @@
"base-64": "^1.0.0",
"crypto-browserify": "^3.12.0",
"date-fns": "^3.6.0",
"expo": "^51.0.32",
"expo": "~51.0.37",
"expo-application": "~5.9.1",
"expo-build-properties": "~0.12.5",
"expo-status-bar": "~1.12.1",

View File

@@ -377,11 +377,23 @@ const DayModal = React.memo(({ date, calendarData, onClose, dayColors, colors, u
);
});
const getDayType = (date, calendarData) => {
const dayType = calendarData.dayTypes.find((d) =>
new Date(d.from) <= date && date <= new Date(d.until)
);
// Set the date to midnight to avoid timezone issues
const targetDate = new Date(date.getFullYear(), date.getMonth(), date.getDate());
const dayType = calendarData.dayTypes.find((d) => {
// Create midnight dates for comparison
const fromDate = new Date(d.from);
const untilDate = new Date(d.until);
// Set both dates to midnight
fromDate.setHours(0, 0, 0, 0);
untilDate.setHours(0, 0, 0, 0);
return fromDate <= targetDate && targetDate <= untilDate;
});
console.log(targetDate, dayType);
return dayType ? dayType.type : "schultag";
};