fix: improve holiday name retrieval by comparing year, month, and day directly to avoid timezone issues

refactor: change exported variables to local scope in state management for better encapsulation
This commit is contained in:
Felix Schlusche
2025-10-23 19:36:55 +02:00
parent 426859ea0d
commit af23aa369c
3 changed files with 63 additions and 64 deletions

View File

@@ -129,11 +129,16 @@ function getPublicHolidays(year, bundesland) {
*/
function getHolidayName(date) {
const year = date.getFullYear();
const month = date.getMonth();
const day = date.getDate();
const holidays = getPublicHolidays(year, currentBundesland);
const dateStr = date.toISOString().split('T')[0];
// Compare year, month, and day directly (avoid timezone issues)
const holiday = holidays.find(h => {
return h.date.toISOString().split('T')[0] === dateStr;
return h.date.getFullYear() === year &&
h.date.getMonth() === month &&
h.date.getDate() === day;
});
return holiday ? holiday.name : null;