This is a very simplistic parser for string values according to the OSM opening hours specification.
It parses 144'319 (89%) of 161'268 unique test strings in non-strict mode. The remaining 16'949 are likely valid errors, spot checking shows that they have obvious issues. In strict mode further 12'546 fail.
Deviations from the grammar as of this version of the opening hours specification in all modes:
- case insensitive
- minutes in times optional
- leading 0s in times optional
- unicode EN DASH character is allowed for hyphen
In non-strict mode the following further differences are allowed:
- three-character weekday abbreviations
- times extending in to the next day that are missing the extra 24 hours are corrected
- AM and PM time specifications are allowed
Converting the data structures generated by parsing back to strings will result in correct data according to the specification.
try {
OpeningHoursParser parser = new OpeningHoursParser(
new ByteArrayInputStream(line.getBytes()));
ArrayList<Rule> rules = parser.rules(strict);
// ...
} catch() {
// ...
}
You can either download the jar from GitHub or add the following to your build.gradle file(s):
repositories {
maven {
jcenter()
}
}
dependencies {
compile "ch.poole:OpeningHoursParser:0.1.2"
}