Skip to content

realCity/opening-hours-evaluator

 
 

Repository files navigation

OSM opening hours evaluator

This Java package takes opening hours in OSM format and an instance of java.time.LocalDateTime and checks if the POI is open or not at the specified time.

Installation

Maven Central

It's available on Maven Central.

compile group: 'io.leonard', name: 'opening-hours-evaluator', version: '<latest version>'

It depends on Simon Poole's OpeningHoursParser but since that is not on Maven Central, the dependency is bundled inside the Jar.

Usage

Is it open now?

var openingHours = "Mo-Fr 09:00-18:00"
var parser = new OpeningHoursParser(new ByteArrayInputStream(openingHours.getBytes()));
var rules = parser.rules(true);
var time = LocalDateTime.parse("2020-08-07T12:09:17");
OpeningHoursEvaluator.isOpenAt(time, rules);

When is it open next?

var openingHours = "Mo-Fr 09:00-18:00"
var parser = new OpeningHoursParser(new ByteArrayInputStream(openingHours.getBytes()));
var rules = parser.rules(true);
var time = LocalDateTime.parse("2020-08-07T12:09:17");
OpeningHoursEvaluator.isOpenNext(time, rules);

Completeness

Since the opening hours specification is complex, not every feature is supported. To get an idea of what exactly is working, please check the unit test input files open.csv and closed.csv.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Java 99.0%
  • Makefile 1.0%