I need to validate from my Ruby app the format of the openingHours
field used by Open Street Map
.
I found this validator http://openingh.openstreetmap.de/evaluation_tool/ but I was wondering if there was a gem, REST API or at least a known regex to validate the format expected by them.
This is an example of the opening hours format:
Mo, Tu, We, Th, Fr, Sa 10:00-18:00 Su 12:00-17:00
The example from your question is wrong, a semicolon is missing. The correct format is:
Mo,Tu,We,Th,Fr,Sa 10:00-18:00; Su 12:00-17:00
or in short:
Mo-Sa 10:00-18:00; Su 12:00-17:00
.
I don't think a regex can handle this complex format. You will need a real parser. The OSM wiki lists several implementations: