From 684932aebd9348dc5f0224fbfe9b4adafb28a5da Mon Sep 17 00:00:00 2001 From: Pieter Vander Vennet Date: Wed, 19 Jun 2024 02:50:08 +0200 Subject: [PATCH] Linked data loader: ignore days where the shop is probably closes --- src/Logic/Web/LinkedDataLoader.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/Logic/Web/LinkedDataLoader.ts b/src/Logic/Web/LinkedDataLoader.ts index 39729fbad..d07397ad3 100644 --- a/src/Logic/Web/LinkedDataLoader.ts +++ b/src/Logic/Web/LinkedDataLoader.ts @@ -124,7 +124,7 @@ export default class LinkedDataLoader { * // Weird data format from C&A * LinkedDataLoader.ohStringToOsmFormat("MO 09:30-18:00 TU 09:30-18:00 WE 09:30-18:00 TH 09:30-18:00 FR 09:30-18:00 SA 09:30-18:00") // => "Mo-Sa 09:30-18:00" * LinkedDataLoader.ohStringToOsmFormat("MO 09:30-18:00 TU 09:30-18:00 WE 09:30-18:00 TH 09:30-18:00 FR 09:30-18:00 SA 09:30-18:00 SU 09:30-18:00") // => "09:30-18:00" - * + * LinkedDataLoader.ohStringToOsmFormat("MO 09:30-18:00 TU 09:30-18:00 WE 09:30-18:00 TH 09:30-18:00 FR 09:30-18:00 SA 09:30-18:00 SU 00:00-00:00") // => "Mo-Sa 09:30" */ static ohStringToOsmFormat(oh: string) { oh = oh.toLowerCase() @@ -133,7 +133,7 @@ export default class LinkedDataLoader { } const regex = /([a-z]+ [0-9:]+-[0-9:]+) (.*)/ let match = oh.match(regex) - const parts: string[] = [] + let parts: string[] = [] while (match) { parts.push(match[1]) oh = match[2] @@ -141,6 +141,11 @@ export default class LinkedDataLoader { } parts.push(oh) + /* omit expressions as "su 00:00-00:00". This _can_ be interpreted as 'all day long', but will, in practice, indicate that it is closed + Looking at you, C&A! + view-source:https://www.c-and-a.com/stores/be-en/oost-vlaanderen/sint-niklaas/stationsstraat-100.html + * */ + parts = parts.filter(p => !p.match(/.. 00:00-00:00/)) // actually the same as OSM-oh return OH.simplify(parts.join(";")) }