Fix DayTypes
This commit is contained in:
1018
package-lock.json
generated
1018
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@@ -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",
|
||||
|
||||
@@ -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";
|
||||
};
|
||||
|
||||
@@ -441,4 +453,4 @@ function endsNextDayMidnight(start, end) {
|
||||
|
||||
const endTimeIsMidnight = endD.getHours() === 0 && endD.getMinutes() === 0 && endD.getSeconds() === 0;
|
||||
return (daysDifference == 1 || daysDifference == -1) && endTimeIsMidnight
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user