fix regressions in parseOpeningHours, ignore holidays (#1411)

This commit is contained in:
shtrophic
2025-06-01 20:05:12 +02:00
committed by GitHub
parent 9d3bdb4600
commit 6d87230281
2 changed files with 43 additions and 4 deletions
@@ -388,6 +388,8 @@ internal fun parseOpeningSchedule(
}
}
}
} else if (!rule.holidays.isNullOrEmpty()) {
continue // skip PH and SH entries
} else if (!rule.times.isNullOrEmpty() || !rule.months.isNullOrEmpty()) {
rulesMap.forEach { _, it ->
it.add(rule)
@@ -395,14 +397,12 @@ internal fun parseOpeningSchedule(
}
}
// Filter out rules that are not valid for the current year, month, and week. Hopefully,
// there is only one rule left per weekday. If not, skip that weekday.
val applicableRules = rulesMap.mapNotNull { (day, rules) ->
// Filter out rules that are not valid for the current year, month, and week.
val applicableRules = rulesMap.flatMap { (day, rules) ->
rules.filterYears(localTime)
.filterMonths(localTime)
.filterNthDays(localTime)
.map { it.copy(weekdays = listOf(day)) }
.singleOrNull()
}
val hours = mutableSetOf<OpeningHours>()