simonpoole / OpeningHoursParser

Parser for string values according to the OSM opening hours specification
MIT License
32 stars 12 forks source link

Ignoring of dangling `,` after wide range inconsistent #89

Open westnordost opened 10 months ago

westnordost commented 10 months ago

This parser, and also the reference implementation ignores a dangling , at the end of a wide range.

E.g. Apr-Oct,Mo-Fr 08:00-18:00 is (interpreted as and) changed to
Apr-Oct Mo-Fr 08:00-18:00

If it was not changed, the , would be an additional rule separator, making the whole expression mean something else.

This is not documented in the specification, but as far as I can see, it makes sense:

For all opening hours strings I've looked at that had such a dangling , , this parsing behavior made sense - for it each matched the intention of the author. In any case, while this behavior is consistent in opening_hours.js, it is only done in specific situations for this parser:

, is removed

Apr-Oct, Mo 08:00-18:00 Apr, Mo 08:00-18:00 Apr, Mo 08:00 2024, Mo 08:00 Apr 01, Mo 08:00 Apr 01, Mo sunrise 2024, Mo,PH 08:00 week 01-52, Mo 08:00

, is not removed (-> additional rule)

Apr, 08:00 2024, 08:00 Apr, sunrise 2024, PH 08:00 2024, PH,Mo 08:00

In conclusion, , is only removed if a weekday (not PH/SH!) follows any wide range selector

simonpoole commented 8 months ago

This would seem to be related to https://github.com/simonpoole/OpeningHoursParser/issues/81