I recently wrote about KOpeningHours, a new library to parse and interpret OSM opening hours expressions. Here is now how we make use of this in KDE Itinerary.

Highlight Open Entities

Based on your travel bookings KDE Itinerary knows when and for how long you are going to be at a train station or airport. Combined with now understanding opening hours information we can determine which shop, restaurant, amenity or other entity is open during that time span. Things closed for your entire stay will be grayed out on the station map.

Train station map using colored icons for open shops/restaurants/amenities, and gray ones for those closed ones.
Shops, restaurants or amenities closed during a layover are grayed out.

This of course is most useful at very large stations or airports and shorter layovers, where walking longer distances in vain would be rather inconvenient.

Human-readable Opening Hours

Another place where we made use of this is the information dialog for a selected element on the map.

Opening hours information for a selected element on the map presented both in textual and visual form.
Textual description of the current opening state and visual overview of the current week.

There are two things in here:

  • A textual description of the current state and the next state change. This is the information you are most likely looking for regarding the opening time.
  • A visual representation of the current week. The benefit of that might be less obvious for simple opening hours expressions like Mo-Fr 09:00-17:00, but as soon as they get slightly more complex interpreting that manually becomes tricky and potentially error prone. Consider for example the simple PH off (closed on public holidays) addition. In your home region you likely know when there is a public holiday, in other countries you might encounter surprises though (remember e.g. Akademy 2018).

Outlook

At this point I considered the opening hours topic sufficiently covered, just leaving the standard KDE review process to be done for integrating this into the 21.04 release service.

Then I however got contacted by an OSM contributor, who, after having imported the opening hours of all French post offices into OSM and finding himself confronted with a number of false-positive warnings by the OSM validator, was looking into improving the Osmose OSM validator for opening hours expressions. KOpeningHours was apparently performing quite well during an evaluation for this, and is therefore being considered as a parser for the validator.

The requirements on the parser for validation are higher than for the evaluation use I had originally in mind. Rejecting to evaluate things we aren’t certain about is enough for KDE Itinerary’s use, however a validator shouldn’t produce false positives and also needs to accepts all kinds of rare edge cases correctly. This has already resulted in a number of improvements to KOpeningHours, which of course also benefit KDE Itinerary.

Said OSM contributor is a certain David Faure btw, the world is very small.