
io.leonard.TimeRange Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of opening-hours-evaluator Show documentation
Show all versions of opening-hours-evaluator Show documentation
Evaluator for OpenStreetMap-formatted opening hours
package io.leonard;
import ch.poole.openinghoursparser.TimeSpan;
import java.time.LocalTime;
import java.util.Comparator;
public class TimeRange {
public final LocalTime start;
public final LocalTime end;
public TimeRange(TimeSpan span) {
this.start = LocalTime.ofSecondOfDay(span.getStart() * 60L);
this.end =
LocalTime.ofSecondOfDay(Math.min(span.getEnd() * 60L, LocalTime.MAX.toSecondOfDay()));
}
public boolean surrounds(LocalTime time) {
return time.isAfter(start) && time.isBefore(end);
}
public static Comparator startComparator =
Comparator.comparing(timeRange -> timeRange.start);
public static Comparator endComparator =
Comparator.comparing(timeRange -> timeRange.end);
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy