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:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user